Skip to content

Commit

Permalink
[FIXED JENKINS-24757] Allow spaces in script parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
vjuranek committed Sep 18, 2014
1 parent e164d48 commit c9c33b1
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/main/java/hudson/plugins/groovy/Groovy.java
Expand Up @@ -284,7 +284,7 @@ protected List<String> buildCommandLine(AbstractBuild build, BuildListener liste

//Add groovy parameters
if(parameters != null && !parameters.isEmpty()) {
String[] args = parseGroovyCmdLine(parameters);
String[] args = parseParams(parameters);
for(String arg : args) {
list.add(Util.replaceMacro(arg, vr));
}
Expand All @@ -293,18 +293,17 @@ protected List<String> buildCommandLine(AbstractBuild build, BuildListener liste
list.add(script.getRemote());

//Add script parameters
if(scriptParameters != null) {
StringTokenizer tokens = new StringTokenizer(scriptParameters);
if(scriptParameters != null && !scriptParameters.isEmpty()) {
String[] params = parseParams(scriptParameters);
ParametersAction parameters = build.getAction(ParametersAction.class);
while(tokens.hasMoreTokens()) {
String token = tokens.nextToken();
for(String param : params) {
//first replace parameter from parameterized build
if (parameters != null) {
token = parameters.substitute(build, token);
param = parameters.substitute(build, param);
}
//then replace evn vars
token = Util.replaceMacro(token,vr);
list.add(token);
param = Util.replaceMacro(param,vr);
list.add(param);
}
}

Expand All @@ -316,7 +315,7 @@ protected List<String> buildCommandLine(AbstractBuild build, BuildListener liste
* Parse parameters to be passed as arguments to the groovy binary
*
*/
private String[] parseGroovyCmdLine(String line) {
private String[] parseParams(String line) {
CommandLine cmdLine = CommandLine.parse(line);
String[] parsedArgs = cmdLine.getArguments();
String[] args = new String[parsedArgs.length + 1];
Expand Down

0 comments on commit c9c33b1

Please sign in to comment.