Skip to content
Browse files

[FIXED JENKINS-27003] handle null for unresolved variables

  • Loading branch information
danc86 authored and vjuranek committed Feb 18, 2015
1 parent ed00c85 commit 9cfac716c2d72b15f392c53e150de51a6957e084
@@ -12,6 +12,9 @@ public XMLEscapingVariableResolver(VariableResolver<String> inner) {

public String resolve(String name) {
String value = inner.resolve(name);
if (value == null) {
return null;
return value
.replaceAll("&", "&amp;")
.replaceAll(">", "&gt;")
@@ -45,5 +45,23 @@ public void expandBuildParams() throws IOException, ExecutionException, Interrup
"<test>Build #1: My test job with string param of with value My test string parameter &lt; &gt; and boolean param with value true</test>",

public void handlesUndefinedVariableSubstitutions()
throws IOException, InterruptedException, ExecutionException {
FreeStyleProject project = j.createFreeStyleProject();
FreeStyleBuild build = project.scheduleBuild2(0).get();

String jobParamXML = "<job>${SOMETHING_UNDEFINED}</job>";

JobSource job = new StringJobSource("testJob", jobParamXML);
File jobFile = job.createJobFile(build, new StreamBuildListener(
System.out, Charset.defaultCharset()));
BufferedReader br = new BufferedReader(new FileReader(jobFile.getPath()));
String actualJob = br.readLine();
assertEquals("<job>${SOMETHING_UNDEFINED}</job>", actualJob);


0 comments on commit 9cfac71

Please sign in to comment.
You can’t perform that action at this time.