Refine search
@Override protected void fix(TaskListener listener) throws Exception { LOGGER.info("Initiating a re-keying of secrets. See "+getLogFile()); SecretRewriter rewriter = new SecretRewriter(); try { PrintStream log = listener.getLogger(); log.println("Started re-keying " + new Date()); int count = rewriter.rewriteRecursive(Jenkins.getInstance().getRootDir(), listener); log.printf("Completed re-keying %d files on %s\n",count,new Date()); new RekeySecretAdminMonitor().done.on(); LOGGER.info("Secret re-keying completed"); } catch (Exception e) { LOGGER.log(Level.SEVERE, "Fatal failure in re-keying secrets",e); Functions.printStackTrace(e, listener.error("Fatal failure in rewriting secrets")); } }
@Override @SuppressFBWarnings("NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE") public void afterDisconnect(SlaveComputer computer, TaskListener listener) { final Slave node = computer.getNode(); if (node != null) { try { Jenkins.getInstance().removeNode(node); } catch (IOException e) { e.printStackTrace(listener.error(e.getMessage())); } } else { listener.getLogger().printf("Could not remove node for %s as it appears to have been removed already%n", computer); } } };
listener.getLogger().println("Cycle detected: "+dir); return 0; if (cn.endsWith(".xml")) { if ((count++)%100==0) listener.getLogger().println("Scanning "+child); try { if (rewrite(child)) { listener.getLogger().println("Rewritten "+child); rewritten++; Functions.printStackTrace(e, listener.error("Failed to rewrite " + child));
/** * Gets the version of used Mercurial installation. */ public @CheckForNull String version() throws IOException, InterruptedException { String version = popen(null, listener, false, new ArgumentListBuilder("version")); if (version.isEmpty()) { listener.error(Messages.HgExe_expected_to_get_hg_version_name_but_got_nothing()); return null; } Matcher m = Pattern.compile("^Mercurial Distributed SCM [(]version ([0-9][^)]*)[)]$", Pattern.MULTILINE).matcher(version); if (!m.find() || m.groupCount() < 1) { listener.getLogger().print(version); listener.error(Messages.HgExe_cannot_extract_hg_version()); return null; } return m.group(1); }
/** * Examines the file and returns true if a file was deleted. */ private boolean check(File fingerprintFile, TaskListener listener) { try { Fingerprint fp = loadFingerprint(fingerprintFile); if (fp == null || !fp.isAlive()) { listener.getLogger().println("deleting obsolete " + fingerprintFile); fingerprintFile.delete(); return true; } else { // get the fingerprint in the official map so have the changes visible to Jenkins // otherwise the mutation made in FingerprintMap can override our trimming. fp = getFingerprint(fp); return fp.trim(); } } catch (IOException e) { Functions.printStackTrace(e, listener.error("Failed to process " + fingerprintFile)); return false; } }
@Override public GitHubPRCause check(@Nonnull GitHubPRDecisionContext prDecisionContext) throws IOException { TaskListener listener = prDecisionContext.getListener(); GHPullRequest remotePR = prDecisionContext.getRemotePR(); final PrintStream logger = listener.getLogger(); Boolean mergeable; try { mergeable = remotePR.getMergeable(); } catch (IOException e) { listener.error(DISPLAY_NAME + ": can't get mergeable status {}", e); LOGGER.warn("Can't get mergeable status: {}", e); mergeable = false; } mergeable = mergeable != null ? mergeable : false; if (!mergeable) { return prDecisionContext.newCause(DISPLAY_NAME, isSkip()); } return null; }
/** * Runs the command and captures the output. */ public String popen(FilePath repository, TaskListener listener, boolean useTimeout, ArgumentListBuilder args) throws IOException, InterruptedException { args = seed(false).add(args.toCommandArray()); ByteArrayOutputStream rev = new ByteArrayOutputStream(); if (MercurialSCM.joinWithPossibleTimeout(l(args).pwd(repository).stdout(rev), useTimeout, listener) == 0) { return rev.toString(); } else { listener.error("Failed to run " + args.toStringWithQuote()); listener.getLogger().write(rev.toByteArray()); throw new AbortException(); } }
continue; // children will typically have their own workspaces as subdirectories; probably no real workspace of its own listener.getLogger().println("Checking " + item.getFullDisplayName()); for (Node node : nodes) { FilePath ws = node.getWorkspaceFor(item); check = shouldBeDeleted(item, ws, node); } catch (IOException x) { Functions.printStackTrace(x, listener.error("Failed to check " + node.getDisplayName())); continue; } catch (InterruptedException x) { Functions.printStackTrace(x, listener.error("Failed to check " + node.getDisplayName())); continue; listener.getLogger().println("Deleting " + ws + " on " + node.getDisplayName()); try { ws.deleteRecursive(); WorkspaceList.tempDir(ws).deleteRecursive(); } catch (IOException x) { Functions.printStackTrace(x, listener.error("Failed to delete " + ws + " on " + node.getDisplayName())); } catch (InterruptedException x) { Functions.printStackTrace(x, listener.error("Failed to delete " + ws + " on " + node.getDisplayName()));
/** * Runs the command and captures the output. */ @NonNull public String popen(FilePath repository, TaskListener listener, boolean useTimeout, ArgumentListBuilder args) throws IOException, InterruptedException { args = seed(false).add(args.toCommandArray()); ByteArrayOutputStream data = new ByteArrayOutputStream(); if (joinWithPossibleTimeout(launch(args).pwd(repository).stdout(data), useTimeout, listener) == 0) { try { //TODO: consider using another charset return data.toString(Charset.defaultCharset().name()); } catch (UnsupportedCharsetException ex) { // Should never happen throw new IOException("Cannot perform a conversion using the default charset", ex); } } else { listener.error("Failed to run " + args.toStringWithQuote()); listener.getLogger().write(data.toByteArray()); throw new AbortException(); } }
PrintStream out = listener.getLogger(); ZFSFileSystem existing = zfs.getFileSystemByMountPoint(home); if(existing!=null) { out.println(home+" is already on ZFS. Doing nothing"); return true; out.println("Opening "+target); ZFSFileSystem hudson = zfs.open(target, ZFSFileSystem.class); hudson.setMountPoint(tmpDir); out.println("Copying all existing data files"); if(system(home,listener, "/usr/bin/cp","-pR",".", tmpDir.getAbsolutePath())!=0) { out.println("Failed to copy "+home+" to "+tmpDir); hudson.share(); } catch (ZFSException e) { listener.error("Failed to share the file systems: "+e.getCode());
public void run() { // this would fail if the connection is already lost, so we want to check that. // TODO: Connection class should expose whether it is still connected or not. SFTPv3Client sftpClient = null; try { sftpClient = new SFTPv3Client(connection); sftpClient.rm(fileName); } catch (Exception e) { if (sftpClient == null) {// system without SFTP try { connection.exec("rm " + fileName, listener.getLogger()); } catch (Error error) { throw error; } catch (Throwable x) { x.printStackTrace(listener.error(Messages.SSHLauncher_ErrorDeletingFile(getTimestamp()))); // We ignore other Exception types } } else { e.printStackTrace(listener.error(Messages.SSHLauncher_ErrorDeletingFile(getTimestamp()))); } } finally { if (sftpClient != null) { sftpClient.close(); } } } });
listener.getLogger().println("Skipping installation of " + archive + " to " + remote + ": " + x); listener.getLogger().println("Following redirect " + archive.toExternalForm() + " -> " + location); return installIfNecessaryFrom(getUrlFactory().newURL(location), listener, message, maxRedirects - 1); } else { listener.getLogger().println("Skipping installation of " + archive + " to " + remote + " due to too many redirects."); return false; } catch (IOException x) { if (listener != null) { Functions.printStackTrace(x, listener.error("Failed to download " + archive + " from agent; will retry from master"));
public void run() { // this would fail if the connection is already lost, so we want to check that. // TODO: Connection class should expose whether it is still connected or not. SFTPv3Client sftpClient = null; try { sftpClient = new SFTPv3Client(connection); sftpClient.rm(fileName); } catch (Exception e) { if (sftpClient == null) {// system without SFTP try { connection.exec("rm " + fileName, listener.getLogger()); } catch (Error error) { throw error; } catch (Throwable x) { x.printStackTrace(listener.error(Messages.SSHLauncher_ErrorDeletingFile(getTimestamp()))); // We ignore other Exception types } } else { e.printStackTrace(listener.error(Messages.SSHLauncher_ErrorDeletingFile(getTimestamp()))); } } finally { if (sftpClient != null) { sftpClient.close(); } } } });
@Override public void perform(Run<?,?> build, FilePath workspace, Launcher launcher, TaskListener listener) throws InterruptedException { try { listener.getLogger().println(Messages.Fingerprinter_Recording()); Map<String,String> record = new HashMap<String,String>(); EnvVars environment = build.getEnvironment(listener); if(targets.length()!=0) { String expandedTargets = environment.expand(targets); record(build, workspace, listener, record, expandedTargets); } FingerprintAction fingerprintAction = build.getAction(FingerprintAction.class); if (fingerprintAction != null) { fingerprintAction.add(record); } else { build.addAction(new FingerprintAction(build,record)); } if (enableFingerprintsInDependencyGraph) { Jenkins.getInstance().rebuildDependencyGraphAsync(); } } catch (IOException e) { Functions.printStackTrace(e, listener.error(Messages.Fingerprinter_Failed())); build.setResult(Result.FAILURE); } // failing to record fingerprints is an error but not fatal }
} catch(IOException e) { if (causedByMissingHg(e)) { listener.error("Failed to determine whether workspace can be reused because hg could not be found;" + " check that you've properly configured your Mercurial installation"); } else { e.printStackTrace(listener.error("Failed to determine whether workspace can be reused")); determineChanges(build, launcher, listener, changelogFile, repository, node, revToBuild, baseline); } catch (IOException e) { listener.error("Failed to capture change log"); e.printStackTrace(listener.getLogger()); throw new AbortException("Failed to capture change log");
MercurialTagAction baseline = (MercurialTagAction)_baseline; PrintStream output = listener.getLogger(); } 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");