Skip to content

Commit

Permalink
[FIXED JENKINS-20744] Don't hold off building jobs copied from CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-beck committed Nov 24, 2013
1 parent d990ed5 commit 19a2246
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion core/src/main/java/hudson/cli/CopyJobCommand.java
Expand Up @@ -75,7 +75,7 @@ protected int run() throws Exception {
dst = dst.substring(i + 1);
}

ig.copy(src,dst);
ig.copy(src,dst).save();
return 0;
}
}
Expand Down
25 changes: 25 additions & 0 deletions test/src/test/java/hudson/cli/CopyJobCommandTest.java
Expand Up @@ -37,6 +37,12 @@
import org.jvnet.hudson.test.JenkinsRule;
import org.jvnet.hudson.test.MockFolder;

import static org.hamcrest.MatcherAssert.assertThat;

import static hudson.cli.CLICommandInvoker.Matcher.hasNoStandardOutput;
import static hudson.cli.CLICommandInvoker.Matcher.hasNoErrorOutput;
import static hudson.cli.CLICommandInvoker.Matcher.succeeded;

@SuppressWarnings("DM_DEFAULT_ENCODING")
public class CopyJobCommandTest {

Expand All @@ -56,4 +62,23 @@ public class CopyJobCommandTest {
// TODO test copying from/to root, or into nonexistent folder
}

// hold off build until saved only makes sense on the UI with config screen shown after copying;
// expect the CLI copy command to leave the job buildable
@Test public void copiedJobIsBuildable() throws Exception {
FreeStyleProject p1 = j.createFreeStyleProject();
String copiedProjectName = "p2";

CLICommandInvoker.Result result = new CLICommandInvoker(j, new CopyJobCommand())
.invokeWithArgs(p1.getName(), copiedProjectName);

assertThat("Command expected to succeed; " + result.stderr() + ' ' + result.stdout(), result, succeeded());
assertThat("stdout empty", result, hasNoStandardOutput());
assertThat("stderr empty", result, hasNoErrorOutput());

FreeStyleProject p2 = (FreeStyleProject)j.jenkins.getItem(copiedProjectName);

assertNotNull(p2);
assertTrue(p2.isBuildable());
}

}

0 comments on commit 19a2246

Please sign in to comment.