summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
author8nevil82011-12-01 08:16:46 (EST)
committer Winston Prakash2011-12-01 20:47:40 (EST)
commit3ad3f056b145655618a4fd958c79fbfdaf79158c (patch)
treee5ee41eb96f1e51a5afc41bd60c86a0c1d16ed0a
parentf19e17b9eddae5c7e9b7c34df54c3c20a27eb0bf (diff)
downloadorg.eclipse.hudson.core-3ad3f056b145655618a4fd958c79fbfdaf79158c.zip
org.eclipse.hudson.core-3ad3f056b145655618a4fd958c79fbfdaf79158c.tar.gz
org.eclipse.hudson.core-3ad3f056b145655618a4fd958c79fbfdaf79158c.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;
}
}