diff --git a/src/main/java/org/jenkinsci/plugins/managedscripts/ScriptBuildStep.java b/src/main/java/org/jenkinsci/plugins/managedscripts/ScriptBuildStep.java
index 5c7da12..8deeda5 100644
--- a/src/main/java/org/jenkinsci/plugins/managedscripts/ScriptBuildStep.java
+++ b/src/main/java/org/jenkinsci/plugins/managedscripts/ScriptBuildStep.java
@@ -44,7 +44,7 @@
* A project that uses this builder can choose a build step from a list of predefined config files that are uses as command line scripts. The hash-bang sequence at the beginning of each file is used
* to determine the interpreter.
*
- *
+ *
* @author Norman Baumann
* @author Dominik Bartholdi (imod)
*/
@@ -64,23 +64,35 @@ public ArgValue(String arg) {
}
}
+ public static class ScriptBuildStepArgs {
+ public final boolean defineArgs;
+ public final ArgValue[] buildStepArgs;
+
+ @DataBoundConstructor
+ public ScriptBuildStepArgs(boolean defineArgs, ArgValue[] buildStepArgs)
+ {
+ this.defineArgs = defineArgs;
+ this.buildStepArgs = buildStepArgs;
+ }
+ }
+
/**
* The constructor used at form submission
- *
+ *
* @param buildStepId
* the Id of the config file
- * @param defineArgs
- * if the passed arguments should be saved (required because of html form submission, which also sends hidden values)
- * @param buildStepArgs
- * list of arguments specified as buildStepargs
+ * @param scriptBuildStepArgs
+ * whether to save the args and arg values (the boolean is required because of html form submission, which also sends hidden values)
*/
@DataBoundConstructor
- public ScriptBuildStep(String buildStepId, boolean defineArgs, ArgValue[] buildStepArgs) {
+ public ScriptBuildStep(String buildStepId, ScriptBuildStepArgs scriptBuildStepArgs)
+ {
this.buildStepId = buildStepId;
List l = null;
- if (defineArgs && buildStepArgs != null) {
+ if (scriptBuildStepArgs != null && scriptBuildStepArgs.defineArgs
+ && scriptBuildStepArgs.buildStepArgs != null) {
l = new ArrayList();
- for (ArgValue arg : buildStepArgs) {
+ for (ArgValue arg : scriptBuildStepArgs.buildStepArgs) {
l.add(arg.arg);
}
}
@@ -217,7 +229,7 @@ public String getDisplayName() {
/**
* Return all config files (templates) that the user can choose from when creating a build step. Ordered by name.
- *
+ *
* @return A collection of config files of type {@link ScriptConfig}.
*/
public Collection getAvailableBuildTemplates() {
@@ -232,7 +244,7 @@ public int compare(Config o1, Config o2) {
/**
* Returns a Config object for a given config file Id.
- *
+ *
* @param id
* The Id of a config file.
* @return If Id can be found a Config object that represents the given Id is returned. Otherwise null.
@@ -243,7 +255,7 @@ public ScriptConfig getBuildStepConfigById(String id) {
/**
* gets the argument description to be displayed on the screen when selecting a config in the dropdown
- *
+ *
* @param configId
* the config id to get the arguments description for
* @return the description
@@ -270,9 +282,15 @@ public String getArgsDescription(String configId) {
return "please select a script!";
}
+ @JavaScriptMethod
+ public List getArgs(String configId) {
+ final ScriptConfig config = getBuildStepConfigById(configId);
+ return config.args;
+ }
+
/**
* validate that an existing config was chosen
- *
+ *
* @param value
* the configId
* @return
diff --git a/src/main/java/org/jenkinsci/plugins/managedscripts/WinBatchBuildStep.java b/src/main/java/org/jenkinsci/plugins/managedscripts/WinBatchBuildStep.java
index 9c5c6ce..7401d26 100644
--- a/src/main/java/org/jenkinsci/plugins/managedscripts/WinBatchBuildStep.java
+++ b/src/main/java/org/jenkinsci/plugins/managedscripts/WinBatchBuildStep.java
@@ -27,7 +27,7 @@
/**
* A project that uses this builder can choose a build step from a list of predefined windows batch files that are used as command line scripts.
*
- *
+ *
* @author Dominik Bartholdi (imod)
* @see hudson.tasks.BatchFile
*/
@@ -44,23 +44,33 @@ public ArgValue(String arg) {
}
}
+ public static class ScriptBuildStepArgs {
+ public final boolean defineArgs;
+ public final ArgValue[] buildStepArgs;
+
+ @DataBoundConstructor
+ public ScriptBuildStepArgs(boolean defineArgs, ArgValue[] buildStepArgs)
+ {
+ this.defineArgs = defineArgs;
+ this.buildStepArgs = buildStepArgs;
+ }
+ }
/**
* The constructor used at form submission
- *
+ *
* @param buildStepId
* the Id of the config file
- * @param defineArgs
- * if the passed arguments should be saved (required because of html form submission, which also sends hidden values)
- * @param buildStepArgs
- * list of arguments specified as buildStepargs
+ * @param scriptBuildStepArgs
+ * whether to save the args and arg values (the boolean is required because of html form submission, which also sends hidden values)
*/
@DataBoundConstructor
- public WinBatchBuildStep(String buildStepId, boolean defineArgs, ArgValue[] buildStepArgs) {
+ public WinBatchBuildStep(String buildStepId, ScriptBuildStepArgs scriptBuildStepArgs) {
super(buildStepId);
List l = null;
- if (defineArgs && buildStepArgs != null) {
+ if (scriptBuildStepArgs != null && scriptBuildStepArgs.defineArgs
+ && scriptBuildStepArgs.buildStepArgs != null) {
l = new ArrayList();
- for (ArgValue arg : buildStepArgs) {
+ for (ArgValue arg : scriptBuildStepArgs.buildStepArgs) {
l.add(arg.arg);
}
}
@@ -69,7 +79,7 @@ public WinBatchBuildStep(String buildStepId, boolean defineArgs, ArgValue[] buil
/**
* The constructor
- *
+ *
* @param buildStepId
* the Id of the config file
* @param buildStepArgs
@@ -153,7 +163,7 @@ public String getDisplayName() {
/**
* Return all batch files (templates) that the user can choose from when creating a build step. Ordered by name.
- *
+ *
* @return A collection of batch files of type {@link WinBatchConfig}.
*/
public Collection getAvailableBuildTemplates() {
@@ -168,7 +178,7 @@ public int compare(Config o1, Config o2) {
/**
* Returns a Config object for a given config file Id.
- *
+ *
* @param id
* The Id of a config file.
* @return If Id can be found a Config object that represents the given Id is returned. Otherwise null.
@@ -179,7 +189,7 @@ public WinBatchConfig getBuildStepConfigById(String id) {
/**
* gets the argument description to be displayed on the screen when selecting a config in the dropdown
- *
+ *
* @param configId
* the config id to get the arguments description for
* @return the description
@@ -206,9 +216,15 @@ public String getArgsDescription(String configId) {
return "please select a script!";
}
+ @JavaScriptMethod
+ public List getArgs(String configId) {
+ final WinBatchConfig config = getBuildStepConfigById(configId);
+ return config.args;
+ }
+
/**
* validate that an existing config was chosen
- *
+ *
* @param value
* the configId
* @return
diff --git a/src/main/resources/org/jenkinsci/plugins/managedscripts/ScriptBuildStep/config.jelly b/src/main/resources/org/jenkinsci/plugins/managedscripts/ScriptBuildStep/config.jelly
index 88abe96..958078a 100644
--- a/src/main/resources/org/jenkinsci/plugins/managedscripts/ScriptBuildStep/config.jelly
+++ b/src/main/resources/org/jenkinsci/plugins/managedscripts/ScriptBuildStep/config.jelly
@@ -1,67 +1,69 @@
-
-
-
-
-
-
-
-
-
-
-
- No build templates are defined. Please define one
- here.
-