Skip to content

Commit

Permalink
Fix JENKINS-13412
Browse files Browse the repository at this point in the history
  • Loading branch information
gboissinot committed Apr 11, 2012
1 parent 8eb18ad commit ff6465b
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions src/main/java/hudson/plugins/gradle/Gradle.java
Expand Up @@ -11,8 +11,8 @@
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.StaplerRequest;

import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;


Expand Down Expand Up @@ -157,7 +157,7 @@ private boolean performTask(boolean dryRun, AbstractBuild<?, ?> build, Launcher
}
args.add(exe);
}
args.addKeyValuePairs("-D", build.getBuildVariables());
args.addKeyValuePairs("-D", fixParameters(build.getBuildVariables()));
args.addTokenized(normalizedSwitches);
args.addTokenized(normalizedTasks);
if (buildFile != null && buildFile.trim().length() != 0) {
Expand Down Expand Up @@ -218,6 +218,28 @@ private boolean performTask(boolean dryRun, AbstractBuild<?, ?> build, Launcher
}
}

private Map<String, String> fixParameters(Map<String, String> parmas) {
Map<String, String> result = new HashMap<String, String>();
for (Map.Entry<String, String> entry : parmas.entrySet()) {
String value = entry.getValue();
if (isXmlValue(value)) {
result.put(entry.getKey(), "\"" + value + "\"");
} else {
result.put(entry.getKey(), value);
}
}
return result;
}

private boolean isXmlValue(String value) {
if (value == null) {
return false;
}
if (value.trim().length() == 0) {
return false;
}
return value.contains("<") && (value.contains("</") || value.contains("/>"));
}

@Override
public DescriptorImpl getDescriptor() {
Expand Down

0 comments on commit ff6465b

Please sign in to comment.