aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
author8nevil82011-12-01 08:16:46 (EST)
committerWinston Prakash2011-12-01 20:47:40 (EST)
commitb5cbfc7ee5f29844f9981f8fedf0b4ae1885f87f (patch)
treeb62265872ea604a1fc152b2b9ef98c85a1101d4d
parente8b628982aa03df8a981037a7765e3ff68aeb21f (diff)
downloadorg.eclipse.hudson.core-b5cbfc7ee5f29844f9981f8fedf0b4ae1885f87f.zip
org.eclipse.hudson.core-b5cbfc7ee5f29844f9981f8fedf0b4ae1885f87f.tar.gz
org.eclipse.hudson.core-b5cbfc7ee5f29844f9981f8fedf0b4ae1885f87f.tar.bz2
Resolve issue Hudson-9084 (hudson-cli.jar copy-job is broken it creates a non-runnable job)
Signed-off-by: Winston Prakash <winston.prakash@gmail.com>
-rw-r--r--hudson-core/src/main/java/hudson/cli/CopyJobCommand.java9
1 files changed, 9 insertions, 0 deletions
diff --git a/hudson-core/src/main/java/hudson/cli/CopyJobCommand.java b/hudson-core/src/main/java/hudson/cli/CopyJobCommand.java
index 4c5b6b7..0c2c704 100644
--- a/hudson-core/src/main/java/hudson/cli/CopyJobCommand.java
+++ b/hudson-core/src/main/java/hudson/cli/CopyJobCommand.java
@@ -17,10 +17,12 @@
package hudson.cli;
import hudson.model.Hudson;
+import hudson.model.Job;
import hudson.model.TopLevelItem;
import hudson.Extension;
import hudson.model.Item;
import org.kohsuke.args4j.Argument;
+import org.kohsuke.args4j.Option;
/**
@@ -41,6 +43,9 @@ public class CopyJobCommand extends CLICommand {
@Argument(metaVar="DST",usage="Name of the new job to be created.",index=1,required=true)
public String dst;
+ @Option(name = "-fs", aliases = {"--force-save"}, usage = "Force saving the destination job in order to enable build functionality.")
+ public boolean forceSave;
+
protected int run() throws Exception {
Hudson h = Hudson.getInstance();
h.checkPermission(Item.CREATE);
@@ -51,6 +56,10 @@ public class CopyJobCommand extends CLICommand {
}
h.copy(src,dst);
+ Job newJob = (Job)Hudson.getInstance().getItem(dst);
+ if (forceSave && null != newJob) {
+ newJob.save();
+ }
return 0;
}
}