private BuildCommand runCancelTask(Builder cancelBuilder) { if (cancelBuilder == null) { return null; } return BuildCommand.compose( echoWithPrefix("Cancel task: %s", cancelBuilder.getDescription()), cancelBuilder.buildCommand(), echoWithPrefix("Task is cancelled")); }
private BuildCommand reportAction(String action) { return echoWithPrefix("%s %s on ${agent.hostname} [${agent.location}]", action, getJobIdentifier().buildLocatorForDisplay()); }
private BuildCommand updateMaterials() { if (!assignment.shouldFetchMaterials()) { return echoWithPrefix("Skipping material update since stage is configured not to fetch materials"); } MaterialRevisions materialRevisions = assignment.materialRevisions(); Materials materials = materialRevisions.getMaterials(); return BuildCommand.compose( materials.cleanUpCommand(workingDirectory()), echoWithPrefix("Start to update materials \n"), materialRevisions.updateToCommand(workingDirectory())); }
private BuildCommand runSingleBuilder(Builder builder) { String runIfConfig = builder.resolvedRunIfConfig().toString(); return BuildCommand.compose( echoWithPrefix("Current job status: passed"), echoWithPrefix("Current job status: failed").runIf("failed"), echoWithPrefix("Task: %s", builder.getDescription()).runIf(runIfConfig), builder.buildCommand() .runIf(runIfConfig) .setOnCancel(runCancelTask(builder.getCancelBuilder()))).runIf(runIfConfig); }
@Override public BuildCommand buildCommand() { String checksumUrl = String.format("/remoting/files/%s/%s/%s", jobIdentifier.buildLocator(), ArtifactLogUtil.CRUISE_OUTPUT_FOLDER, ArtifactLogUtil.MD5_CHECKSUM_FILENAME); return BuildCommand.compose( BuildCommand.echoWithPrefix(String.format("Fetching artifact [%s] from [%s]", getSrc(), jobLocatorForDisplay())), handler.toDownloadCommand(artifactLocator(), checksumUrl, checksumFileHandler.getChecksumFile())); } }
public BuildCommand updateTo(String baseDir, RevisionContext revisionContext) { Revision revision = revisionContext.getLatestRevision(); String workingDir = material.workingdir(new File(baseDir)).getPath(); UrlArgument url = material.getUrlArgument(); return compose( secret(url.forCommandline(), url.forDisplay()), echoWithPrefix("Start updating %s at revision %s from %s", material.updatingTarget(), revision.getRevision(), url.forDisplay()), cloneIfNeeded(workingDir), pull(workingDir), update(workingDir, revision), echoWithPrefix("Done.\n")); }
public BuildCommand updateTo(String baseDir, RevisionContext revisionContext) { Revision revision = revisionContext.getLatestRevision(); String workingDir = material.workingdir(new File(baseDir)).getPath(); UrlArgument url = material.getUrlArgument(); return compose( echoWithPrefix("Start updating %s at revision %s from %s", material.updatingTarget(), revision.getRevision(), url.forDisplay()), secret(url.forCommandline(), url.forDisplay()), cloneIfNeeded(workingDir, revisionContext.numberOfModifications() + 1), fetchRemote(workingDir), unshallowIfNeeded(workingDir, revision, new Integer[]{GitMaterial.UNSHALLOW_TRYOUT_STEP, Integer.MAX_VALUE}), resetWorkingCopy(workingDir, revision), echoWithPrefix("Done.\n")); }
public BuildCommand updateTo(String baseDir, RevisionContext revisionContext) { Revision revision = revisionContext.getLatestRevision(); String workingDir = material.workingdir(new File(baseDir)).getPath(); UrlArgument url = material.getUrlArgument(); return compose( echoWithPrefix(format("Start updating %s at revision %s from %s", material.updatingTarget(), revision.getRevision(), url.forDisplay())), secret(url.forCommandline(), url.forDisplay()), secret(material.getPassword(), "*********************"), cleanupAndUpdate(workingDir, revision).setTest(shouldDoCleanupAndUpdate(workingDir)), freshCheckout(workingDir, revision).setTest(isNotRepository(workingDir)), freshCheckout(workingDir, revision).setTest(test("-nd", workingDir)), freshCheckout(workingDir, revision).setTest(repoUrlChanged(workingDir)), echoWithPrefix(format("Done.\n")) ); }
private BuildCommand freshCheckout(String workingDir, Revision revision) { return compose( echoWithPrefix("Checking out a fresh copy"), cleandir(workingDir).setTest(test("-d", workingDir)), mkdirs(workingDir).setTest(test("-nd", workingDir)), checkout(workingDir, revision) ); }
private BuildCommand cleanWorkingDir() { if (!assignment.shouldCleanWorkingDir()) { return noop(); } return BuildCommand.compose( cleandir(workingDirectory()), echoWithPrefix("Cleaning working directory \"$%s\" since stage is configured to clean working directory", workingDirectory()) ).setTest(test("-d", workingDirectory())); }
public BuildCommand compose() { return BuildCommand.compose( echoWithPrefix("Job Started: ${date}"), prepare(), build(), reportAction("Job completed").runIf("any")) .setOnCancel(BuildCommand.compose( reportAction("Job is canceled"), reportAction("Job completed"))); }