Skip to content
Prev Previous commit
Next Next commit
call toString on value
  • Loading branch information
jetersen committed Jan 27, 2020
commit b89ccbcd3a43904b89dd2bb29b550fa9b6fe649f
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public Map<String, Object> customInstantiate(@NonNull Map<String, Object> argume
private static List<String> toKeyValueList(Map<?, ?> map) {
return map.entrySet().stream()
.filter(e -> e.getKey() instanceof String)
.collect(Collectors.toMap(e -> (String)e.getKey(), e -> e.getValue() == null ? "" : (String) e.getValue()))
.collect(Collectors.toMap(e -> (String)e.getKey(), e -> e.getValue() == null ? "" : e.getValue().toString()))
.entrySet().stream()
.map(m -> m.getKey() + "=" + m.getValue())
.collect(Collectors.toList());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,26 @@ public class EnvStepTest {
});
}

@Test public void mapNumbersNested() {
story.addStep(new Statement() {
@Override public void evaluate() throws Throwable {
WorkflowJob p = story.j.jenkins.createProject(WorkflowJob.class, "p");
p.setDefinition(new CpsFlowDefinition(
"node {\n" +
" withEnv([A: 1]) {\n" +
" withEnv([B: 2]) {\n" +
" withEnv([C: true]) {\n" +
" isUnix() ? sh('echo A=$A B=$B C=$C') : bat('echo A=%A% B=%B% C=%C%')\n" +
" }\n" +
" }\n" +
" }\n" +
"}", true));
WorkflowRun b = story.j.assertBuildStatusSuccess(p.scheduleBuild2(0));
story.j.assertLogContains("A=1 B=2 C=true", b);
}
});
}

@Test public void mapNested() {
story.addStep(new Statement() {
@Override public void evaluate() throws Throwable {
Expand Down