Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[FIXED JENKINS-23389] Support checking out on a build slave
  • Loading branch information
randycoulman committed Jun 10, 2014
1 parent aeb1ceb commit 7c63ff0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
Expand Up @@ -174,8 +174,11 @@ public boolean checkout(AbstractBuild<?, ?> build, Launcher launcher, FilePath w
return false;
}

FilePath localChangeLogFile = workspace.createTempFile("store", ".xml");

ArgumentListBuilder builder = prepareCheckoutCommand(storeScript.getPath(),
lastBuildTime, build.getTimestamp(), changeLogFile);
lastBuildTime, build.getTimestamp(),
localChangeLogFile.getRemote());

String output;
try {
Expand All @@ -184,7 +187,10 @@ public boolean checkout(AbstractBuild<?, ?> build, Launcher launcher, FilePath w
throw new AbortException("Error launching command");
}

if (!changeLogFile.exists()) {
if (localChangeLogFile.exists()) {
localChangeLogFile.copyTo(new FilePath(changeLogFile));
localChangeLogFile.delete();
} else {
createEmptyChangeLog(changeLogFile, buildListener, "log");
}

Expand Down Expand Up @@ -254,7 +260,7 @@ ArgumentListBuilder preparePollingCommand(String storeScript) {

ArgumentListBuilder prepareCheckoutCommand(String storeScript,
Calendar lastBuildTime, Calendar currentBuildTime,
File changeLogFile) {
String changeLogFilename) {
DateFormat formatter = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss.SSS");
formatter.setTimeZone(TimeZone.getTimeZone("GMT"));

Expand All @@ -266,7 +272,7 @@ ArgumentListBuilder prepareCheckoutCommand(String storeScript,
builder.add("-blessedAtLeast", minimumBlessingLevel);
builder.add("-since", formatter.format(lastBuildTime.getTime()));
builder.add("-now", formatter.format(currentBuildTime.getTime()));
builder.add("-changelog", changeLogFile.getPath());
builder.add("-changelog", changeLogFilename);

if (generateParcelBuilderInputFile) {
builder.add("-parcelBuilderFile", parcelBuilderInputFilename);
Expand Down
Expand Up @@ -93,7 +93,7 @@ public void preparesCheckoutCommandForOnePackage() {
new PundleSpec(PundleType.PACKAGE, "Package"));
StoreSCM scm = new StoreSCM("Default", "Repo", pundles, "\\d+", "Development", false, "");

ArgumentListBuilder builder = scm.prepareCheckoutCommand("storeScript", lastBuildTime, currentBuildTime, new File("/path/to/changelog.xml"));
ArgumentListBuilder builder = scm.prepareCheckoutCommand("storeScript", lastBuildTime, currentBuildTime, "/path/to/changelog.xml");

assertEquals("storeScript -repository Repo -package Package -versionRegex \\d+ -blessedAtLeast Development -since \"03/07/2012 15:28:35.000\" -now \"06/15/2012 07:23:42.000\" -changelog /path/to/changelog.xml",
builder.toStringWithQuote());
Expand All @@ -105,7 +105,7 @@ public void preparesCheckoutCommandForOneBundle() {
new PundleSpec(PundleType.BUNDLE, "Bundle"));
StoreSCM scm = new StoreSCM("Default", "Repo", pundles, "\\d+", "Development", false, "");

ArgumentListBuilder builder = scm.prepareCheckoutCommand("storeScript", lastBuildTime, currentBuildTime, new File("/path/to/changelog.xml"));
ArgumentListBuilder builder = scm.prepareCheckoutCommand("storeScript", lastBuildTime, currentBuildTime, "/path/to/changelog.xml");

assertContains(builder.toStringWithQuote(), "-bundle Bundle");
}
Expand All @@ -118,7 +118,7 @@ public void preparesCheckoutCommandForMultiplePundles() {
new PundleSpec(PundleType.PACKAGE, "Package with Spaces"));
StoreSCM scm = new StoreSCM("Default", "Repo", pundles, "\\d+", "Development", false, "");

ArgumentListBuilder builder = scm.prepareCheckoutCommand("storeScript", lastBuildTime, currentBuildTime, new File("changelog.xml"));
ArgumentListBuilder builder = scm.prepareCheckoutCommand("storeScript", lastBuildTime, currentBuildTime, "changelog.xml");

assertContains(builder.toStringWithQuote(),
"-package Package -bundle Bundle -package \"Package with Spaces\"");
Expand All @@ -130,7 +130,7 @@ public void preparesCheckoutCommandWithParcelBuilderFile() {
new PundleSpec(PundleType.PACKAGE, "Package"));
StoreSCM scm = new StoreSCM("Default", "Repo", pundles, "\\d+", "Development", true, "parcelsToBuild");

ArgumentListBuilder builder = scm.prepareCheckoutCommand("storeScript", lastBuildTime, currentBuildTime, new File("changelog.xml"));
ArgumentListBuilder builder = scm.prepareCheckoutCommand("storeScript", lastBuildTime, currentBuildTime, "changelog.xml");

assertContains(builder.toStringWithQuote(),
"-parcelBuilderFile parcelsToBuild");
Expand Down

0 comments on commit 7c63ff0

Please sign in to comment.