mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-17 05:52:26 +00:00
Merge pull request #1034 from daniel-beck/fix-copy-job-command
[FIXED JENKINS-20744] Don't hold off building jobs copied from CLI
This commit is contained in:
commit
67f2fe6409
2 files changed
+26
-1
No files matched your search
@@ -75,7 +75,7 @@ public class CopyJobCommand extends CLICommand {
|
||||
dst = dst.substring(i + 1);
|
||||
}
|
||||
|
||||
ig.copy(src,dst);
|
||||
ig.copy(src,dst).save();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,12 @@ import org.junit.Test;
|
||||
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 {
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user