Skip to content

Commit

Permalink
[FIXED JENKINS-27003] handle null for unresolved variables
Browse files Browse the repository at this point in the history
  • Loading branch information
danc86 authored and vjuranek committed Feb 18, 2015
1 parent ed00c85 commit 9cfac71
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
Expand Up @@ -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;")
Expand Down
Expand Up @@ -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>",
actualJob);
}


// https://issues.jenkins-ci.org/browse/JENKINS-27003
@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();
br.close();
assertEquals("<job>${SOMETHING_UNDEFINED}</job>", actualJob);
}

}

0 comments on commit 9cfac71

Please sign in to comment.