final Jenkins jenkins = Jenkins.getActiveInstance(); final HashSet<String> hs = new HashSet<>(); hs.addAll(jobs); job = (AbstractItem) jenkins.getItemByFullName(job_s); job.delete(); } catch (Exception e) { if(hs.size() == 1) { throw e; throw new AbortException(CLI_LISTPARAM_SUMMARY_ERROR_TEXT);
PrintStream log = taskListener.getLogger(); "Launcher {0}'s afterDisconnect method propagated an exception when {1}'s connection was closed: {2}"); lr.setThrown(t); lr.setParameters(new Object[]{launcher, SlaveComputer.this.getName(), t.getMessage()}); logger.log(lr); log.println("WARNING: "+remoteFS +" looks suspiciously like Windows path. Maybe you meant "+remoteFS.replace('\\','/')+"?"); FilePath root = new FilePath(channel,remoteFS); Jenkins.get().getQueue().scheduleMaintenance();
protected int run() throws Exception { Jenkins h = Jenkins.getActiveInstance(); h.checkPermission(PluginManager.UPLOAD_PLUGINS); PluginManager pm = h.getPluginManager(); FilePath f = new FilePath(channel, source); if (f.exists()) { stdout.println(Messages.InstallPluginCommand_InstallingPluginFromLocalFile(f)); String n = name != null ? name : f.getBaseName(); f.copyTo(getTargetFilePath(n)); if (dynamicLoad) Throwable e = p.deploy(dynamicLoad).get().getError(); if (e!=null) { AbortException myException = new AbortException("Failed to install plugin " + source); myException.initCause(e); throw myException; stdout.println(Messages.InstallPluginCommand_NoUpdateCenterDefined()); } else { Set<String> candidates = new HashSet<>(); for (UpdateSite s : h.getUpdateCenter().getSites()) { Data dt = s.getData(); throw new AbortException("Error occurred, see previous output.");
final Jenkins jenkins = Jenkins.getActiveInstance(); final HashSet<String> hs = new HashSet<>(); hs.addAll(nodes); node = jenkins.getNode(node_s); node.toComputer().doDoDelete(); } catch (Exception e) { if(hs.size() == 1) { throw e; throw new AbortException(CLI_LISTPARAM_SUMMARY_ERROR_TEXT);
@Override protected int run() throws Exception { boolean errorOccurred = false; final Jenkins jenkins = Jenkins.getActiveInstance(); final HashSet<String> hs = new HashSet<>(); hs.addAll(nodes); computer = jenkins.getComputer(node_s); computer.cliConnect(force); } catch (Exception e) { if (hs.size() == 1) { throw e; throw new AbortException(CLI_LISTPARAM_SUMMARY_ERROR_TEXT);
@Override protected int run() throws Exception { boolean errorOccurred = false; final Jenkins jenkins = Jenkins.getActiveInstance(); final HashSet<String> hs = new HashSet<>(); hs.addAll(nodes); computer = jenkins.getComputer(node_s); computer.cliDisconnect(cause); } catch (Exception e) { if (hs.size() == 1) { throw e; throw new AbortException(CLI_LISTPARAM_SUMMARY_ERROR_TEXT);
@Override protected int run() throws Exception { boolean errorOccurred = false; final Jenkins jenkins = Jenkins.getActiveInstance(); final HashSet<String> hs = new HashSet<>(nodes); List<String> names = null; computer = jenkins.getComputer(node_s); if (computer == null) { if (names == null) { hudson.model.Messages.Computer_NoSuchSlaveExists(node_s, adv)); computer.cliOnline(); } catch (Exception e) { if (hs.size() == 1) { throw e; throw new AbortException(CLI_LISTPARAM_SUMMARY_ERROR_TEXT);
@Override protected int run() throws Exception { boolean errorOccurred = false; final Jenkins jenkins = Jenkins.get(); final HashSet<String> hs = new HashSet<>(nodes); List<String> names = null; Computer computer = jenkins.getComputer(node_s); if (computer == null) { if (names == null) { hudson.model.Messages.Computer_NoSuchSlaveExists(node_s, adv)); computer.cliOffline(cause); } catch (Exception e) { if (hs.size() == 1) { throw e; throw new AbortException(CLI_LISTPARAM_SUMMARY_ERROR_TEXT);
@Override protected int run() throws Exception { boolean errorOccurred = false; final Jenkins jenkins = Jenkins.getInstance(); final HashSet<String> hs = new HashSet<String>(nodes); List<String> names = null; Computer computer = jenkins.getComputer(node_s); if (computer == null) { if (names == null) { hudson.model.Messages.Computer_NoSuchSlaveExists(node_s, adv)); computer.cliOffline(cause); } catch (Exception e) { if (hs.size() == 1) { throw e; throw new AbortException(CLI_LISTPARAM_SUMMARY_ERROR_TEXT);
Node node = Jenkins.get(); if (build.getParent() instanceof TopLevelItem) { dir = new FilePath(owner.getRootDir()); listener.getLogger().println("Checking out " + scm.getKey() + " into " + dir + " to read " + expandedScriptPath); String script = null; Computer computer = node.toComputer(); delegate.setChangelog(true); FilePath acquiredDir; try (WorkspaceList.Lease lease = computer.getWorkspaceList().acquire(dir)) { for (int retryCount = Jenkins.get().getScmCheckoutRetryCount(); retryCount >= 0; retryCount--) { try { delegate.checkout(build, dir, listener, node.createLauncher(listener)); if (e.getMessage() != null) { listener.error(e.getMessage()); throw new AbortException("Maximum checkout retry attempts reached, aborting"); FilePath scriptFile = dir.child(expandedScriptPath); if (!scriptFile.absolutize().getRemote().replace('\\', '/').startsWith(dir.absolutize().getRemote().replace('\\', '/') + '/')) { // TODO JENKINS-26838 throw new IOException(scriptFile + " is not inside " + dir); throw new AbortException(scriptFile + " not found");
FilePath libDir = new FilePath(execution.getOwner().getRootDir()).child("libs/" + name); retriever.retrieve(name, version, changelog, libDir, run, listener); for (String root : new String[] {"src", "vars"}) { String rel = root + "/" + clazz.replace('.', '/') + ".groovy"; FilePath f = libDir.child(rel); if (f.exists()) { String replacement = ReplayAction.replace(execution, clazz); if (replacement != null) { listener.getLogger().println("Replacing contents of " + rel); f.write(replacement, null); // TODO as below, unsure of encoding used by Groovy compiler throw new AbortException("Library " + name + " expected to contain at least one of src or vars directories");
private void update(Run<?, ?> build, Launcher launcher, FilePath repository, Node node, TaskListener listener, String toRevision, StandardUsernameCredentials credentials) throws IOException, InterruptedException { HgExe hg = new HgExe(findInstallation(getInstallation()), credentials, launcher, node, listener, build.getEnvironment(listener)); EnvVars env = build.getEnvironment(listener); try { int pullExitCode; throw new AbortException("Failed to pull"); listener.error("Failed to pull"); throw new AbortException("Failed to pull"); listener.error("Failed to update"); e.printStackTrace(listener.getLogger()); throw new AbortException("Failed to update"); listener.error("Failed to update"); throw new AbortException("Failed to update"); if (build.getNumber() % 100 == 0) { CachedRepo cachedSource = cachedSource(node, env, launcher, listener, true, credentials); if (cachedSource != null && !cachedSource.isUseSharing()) { if (hg.cleanAll().pwd(repository).join() != 0) { listener.error("Failed to clean unversioned files"); throw new AbortException("Failed to clean unversioned files");
@Override public void perform(@Nonnull Run<?, ?> run, @Nonnull FilePath ws, @Nonnull Launcher launcher, @Nonnull TaskListener listener) throws InterruptedException, IOException { if (debug) { listener.getLogger().println("NUnit publisher running in debug mode."); EnvVars env = run.getEnvironment(listener); String resolvedTestResultsPattern = env.expand(testResultsPattern); listener.getLogger().println("Recording NUnit tests results"); NUnitArchiver transformer = new NUnitArchiver(ws.getRemote(), listener, resolvedTestResultsPattern, new NUnitReportTransformer(), failIfNoResults); result = ws.act(transformer); listener.getLogger().println("Skipping feeding JUnit reports to JUnitArchiver"); } else { listener.getLogger().println("Skipping deletion of temporary JUnit reports."); } else { ws.child(NUnitArchiver.JUNIT_REPORTS_PATH).deleteRecursive(); run.setResult(Result.FAILURE); } catch (IOException e) { listener.getLogger().println("Error in NUnit processing: " + e.getMessage()); throw new AbortException("Could not read the XSL XML file. Please report this issue to the plugin author");
@SuppressFBWarnings(value="RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE", justification="TODO 1.653+ switch to Jenkins.getInstanceOrNull") @Override public PollingResult poll(TaskListener listener) { if (!isBuildable()) { listener.getLogger().println("Build disabled"); return PollingResult.NO_CHANGES; listener.getLogger().println("no previous build to compare to"); for (WorkflowRun.SCMCheckout co : perhapsCompleteBuild.checkouts(listener)) { if (!co.scm.supportsPolling()) { listener.getLogger().println("polling not supported from " + co.workspace + " on " + co.node); continue; Computer c = j.getComputer(co.node); if (c == null) { listener.error("no such computer " + co.node); continue; workspace = new FilePath(c.getChannel(), co.workspace); launcher = workspace.createLauncher(listener).decorateByEnv(getEnvironment(c.getNode(), listener)); lease = c.getWorkspaceList().acquire(workspace, !isConcurrentBuild()); } else { workspace = null; listener.error("polling failed in " + co.workspace + " on " + co.node + ": " + x.getMessage()); } catch (Exception x) { listener.error("polling failed in " + co.workspace + " on " + co.node).println(Functions.printThrowable(x).trim()); // TODO 2.43+ use Functions.printStackTrace
@Override public void perform(Run<?,?> build, FilePath ws, Launcher launcher, TaskListener listener) throws IOException, InterruptedException { if(artifacts.length()==0) { throw new AbortException(Messages.ArtifactArchiver_NoIncludes()); Result result = build.getResult(); if (onlyIfSuccessful && result != null && result.isWorseThan(Result.UNSTABLE)) { listener.getLogger().println(Messages.ArtifactArchiver_SkipBecauseOnlyIfSuccessful()); return; listener.getLogger().println(Messages.ArtifactArchiver_ARCHIVING_ARTIFACTS()); try { String artifacts = build.getEnvironment(listener).expand(this.artifacts); Map<String,String> files = ws.act(new ListFiles(artifacts, excludes, defaultExcludes, caseSensitive)); if (!files.isEmpty()) { build.pickArtifactManager().archive(ws, launcher, BuildListenerAdapter.wrap(listener), files); if (fingerprint) { new Fingerprinter(artifacts).perform(build, ws, launcher, listener); listener.getLogger().println(Messages.ArtifactArchiver_NoMatchFound(artifacts)); } else { throw new AbortException(Messages.ArtifactArchiver_NoMatchFound(artifacts)); throw new AbortException(e.toString()); // Message is not enough as that is the filename only
/** * Makes sure that SSH connection won't produce any unwanted text, which will interfere with sftp execution. */ private void verifyNoHeaderJunk(TaskListener listener) throws IOException, InterruptedException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); connection.exec("true",baos); final String s; //TODO: Seems we need to retrieve the encoding from the connection destination try { s = baos.toString(Charset.defaultCharset().name()); } catch (UnsupportedEncodingException ex) { // Should not happen throw new IOException("Default encoding is unsupported", ex); } if (s.length()!=0) { listener.getLogger().println(Messages.SSHLauncher_SSHHeaderJunkDetected()); listener.getLogger().println(s); throw new AbortException(); } }
TaskListener listener, SCMRevisionState _baseline) throws IOException, InterruptedException { final Jenkins jenkins = Jenkins.getInstance(); if (jenkins == null) { throw new IOException("Jenkins instance is not ready"); PrintStream output = listener.getLogger(); EnvVars env = project.getEnvironment(jenkins, listener); StandardUsernameCredentials credentials = getCredentials(project, env); launcher = jenkins.createLauncher(listener); CachedRepo possiblyCachedRepo = cachedSource(Jenkins.getInstance(), env, launcher, listener, true, credentials); if (possiblyCachedRepo == null) { throw new IOException("Could not use cache to poll for changes. See error messages above for more details"); FilePath repositoryCache = new FilePath(new File(possiblyCachedRepo.getRepoLocation())); return compare(launcher, listener, baseline, output, jenkins, repositoryCache, project); } catch(IOException e) { if (causedByMissingHg(e)) { listener.error(Messages.MercurialSCM_failed_to_compare_with_remote_repository()); throw new AbortException("Failed to compare with remote repository");
@Override public void perform(Run<?,?> build, FilePath ws, Launcher launcher, TaskListener listener) throws InterruptedException, AbortException { if(artifacts.length()==0) { listener.error(Messages.ArtifactArchiver_NoIncludes()); build.setResult(Result.FAILURE); return; Result result = build.getResult(); if (onlyIfSuccessful && result != null && result.isWorseThan(Result.UNSTABLE)) { listener.getLogger().println(Messages.ArtifactArchiver_SkipBecauseOnlyIfSuccessful()); return; listener.getLogger().println(Messages.ArtifactArchiver_ARCHIVING_ARTIFACTS()); try { String artifacts = build.getEnvironment(listener).expand(this.artifacts); Map<String,String> files = ws.act(new ListFiles(artifacts, excludes, defaultExcludes, caseSensitive)); if (!files.isEmpty()) { build.pickArtifactManager().archive(ws, launcher, BuildListenerAdapter.wrap(listener), files); String msg = null; try { msg = ws.validateAntFileMask(artifacts, FilePath.VALIDATE_ANT_FILE_MASK_BOUND, caseSensitive); } catch (Exception e) { listenerWarnOrError(listener, e.getMessage()); throw new AbortException(e.toString()); // Message is not enough as that is the filename only } catch (IOException e) { Util.displayIOException(e,listener);
ExternalWorkspace exws = step.getExternalWorkspace(); if (exws == null) { throw new AbortException("No external workspace provided. Did you run the exwsAllocate step?"); Node node = computer.getNode(); if (node == null) { throw new Exception("The node is not live due to some unexpected conditions: the node might have been taken offline, or may have been removed"); NodeDiskPool nodeDiskPool; listener.getLogger().println("Searching for disk definitions in the External Workspace Templates from Jenkins global config"); Template template = findTemplate(node.getLabelString(), step.getDescriptor().getTemplates()); if (nodeDiskPool == null) { String message = format("No Disk Pool Ref ID matching '%s' was found in the External Workspace Template config labeled '%s'", diskPoolId, template.getLabel()); throw new AbortException(message); listener.getLogger().println("Searching for disk definitions in the Node config"); ExternalWorkspaceProperty exwsNodeProperty = findNodeProperty(node); if (nodeDiskPool == null) { String message = format("No Disk Pool Ref ID matching '%s' was found in Node '%s' config", diskPoolId, node.getDisplayName()); throw new AbortException(message); FilePath diskFilePath = new FilePath(node.getChannel(), nodeDisk.getNodeMountPoint()); FilePath workspace = diskFilePath.child(exws.getPathOnDisk());
public static TestResultAction parseAndAttach(@Nonnull JUnitTask task, PipelineTestDetails pipelineTestDetails, Run build, FilePath workspace, Launcher launcher, TaskListener listener) throws InterruptedException, IOException { listener.getLogger().println(Messages.JUnitResultArchiver_Recording()); final String testResults = build.getEnvironment(listener).expand(task.getTestResults()); TestResultAction action = build.getAction(TestResultAction.class); boolean appending; if (action == null) { if (build.getResult() == Result.FAILURE) { listener.getLogger().println(Messages.JUnitResultArchiver_ResultIsEmpty()); return null; throw new AbortException(Messages.JUnitResultArchiver_ResultIsEmpty());