Skip to content

Commit

Permalink
Adding UnitTest for withEnv can contain an equals sign in its value
Browse files Browse the repository at this point in the history
  • Loading branch information
Brenne committed Jan 7, 2022
1 parent ed41bc8 commit 4cb0d4a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
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 4cb0d4a

Please sign in to comment.