diff --git a/src/main/groovy/com/lesfurets/jenkins/unit/BasePipelineTest.groovy b/src/main/groovy/com/lesfurets/jenkins/unit/BasePipelineTest.groovy index 88e9232c..f4548dd9 100644 --- a/src/main/groovy/com/lesfurets/jenkins/unit/BasePipelineTest.groovy +++ b/src/main/groovy/com/lesfurets/jenkins/unit/BasePipelineTest.groovy @@ -269,7 +269,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]) } diff --git a/src/test/groovy/com/lesfurets/jenkins/unit/declarative/TestDeclarativePipeline.groovy b/src/test/groovy/com/lesfurets/jenkins/unit/declarative/TestDeclarativePipeline.groovy index 10a6bde1..fa656cde 100644 --- a/src/test/groovy/com/lesfurets/jenkins/unit/declarative/TestDeclarativePipeline.groovy +++ b/src/test/groovy/com/lesfurets/jenkins/unit/declarative/TestDeclarativePipeline.groovy @@ -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() diff --git a/src/test/jenkins/jenkinsfiles/WithEnvEquals_Jenkinsfile b/src/test/jenkins/jenkinsfiles/WithEnvEquals_Jenkinsfile new file mode 100644 index 00000000..10c304de --- /dev/null +++ b/src/test/jenkins/jenkinsfiles/WithEnvEquals_Jenkinsfile @@ -0,0 +1,12 @@ +pipeline { + agent any + stages { + stage('withenvequals') { + steps { + withEnv(["SOMEVAR=SOMETHING=SOME_OTHER_VAR"]) { + echo "SOMEVAR inside closure = ${env.SOMEVAR}" + } + } + } + } +}