Skip to content

Commit

Permalink
Create additional test for DockerDSL
Browse files Browse the repository at this point in the history
To check that environment variables with spaces are escaped before passing them to container.
  • Loading branch information
Alex Pykavy committed Feb 27, 2021
1 parent d117f74 commit 625940f
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -400,4 +400,21 @@ private static void grep(File dir, String text, String prefix, Set<String> match
}
});
}

@Test public void insideContextOfEnvironmentVariablesWithSpecialCharacters(){
story.addStep(new Statement() {
@Override public void evaluate() throws Throwable {
assumeDocker();
WorkflowJob p = story.j.jenkins.createProject(WorkflowJob.class, "prj");
p.setDefinition(new CpsFlowDefinition(
"node {\n" +
" withEnv(['ENV_VAR=\"VARIABLE = VALUE WITH QUOTES \\\" AND SPACES \\\"\"']) {\n" +
" docker.image('busybox').inside { sh 'env' }\n" +
" }\n" +
"}", true));
WorkflowRun r = story.j.assertBuildStatusSuccess(p.scheduleBuild2(0));
story.j.assertLogContains("ENV_VAR=\"VARIABLE = VALUE WITH QUOTES \" AND SPACES \"\"", r);
}
});
}
}

0 comments on commit 625940f

Please sign in to comment.