Skip to content

Commit

Permalink
Merge pull request #468 from Brenne/bugfix_388
Browse files Browse the repository at this point in the history
Split withEnv only on first `=` character
  • Loading branch information
nre-ableton committed Jan 10, 2022
2 parents ee31dd9 + c859e43 commit 45841ba
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ abstract class BasePipelineTest {
}

list.each {
def item = it.split('=')
def item = it.split('=', 2)
assert item.size() == 2, "withEnv list does not look right: ${list.toString()}"
addEnvVar(item[0], item[1])
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,13 @@ class TestDeclarativePipeline extends DeclarativePipelineTest {
assertCallStack().contains('echo(SOMEVAR outside closure = null)')
}

@Test void withEnv_can_have_equals_in_value() throws Exception {
runScript('WithEnvEquals_Jenkinsfile')
printCallStack()
assertCallStack().contains('SOMEVAR inside closure = SOMETHING=SOME_OTHER_VAR')
assertJobStatusSuccess()
}

@Test void agent_with_param_label() throws Exception {
runScript('AgentParam_Jenkinsfile')
printCallStack()
Expand Down
12 changes: 12 additions & 0 deletions src/test/jenkins/jenkinsfiles/WithEnvEquals_Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
pipeline {
agent any
stages {
stage('withenvequals') {
steps {
withEnv(["SOMEVAR=SOMETHING=SOME_OTHER_VAR"]) {
echo "SOMEVAR inside closure = ${env.SOMEVAR}"
}
}
}
}
}

0 comments on commit 45841ba

Please sign in to comment.