Closed axieum closed 4 months ago
Given the following Jenkins script -
withEnv(['MYTOOL_HOME=/usr/local/mytool']) { sh label: 'lorem', script: '$MYTOOL_HOME/bin/start' }
And the following unit test groovy -
MethodCall call = helper.callStack.find { call -> call.methodName = 'sh' } assertEquals('$MYTOOL_HOME/bin/start', call.args[0]['script'])
Given environment variables are evaluated by the OS, and the environment variables only live within the withEnv { ... } block, how can these be asserted, to make sure the sh script is running with the correct environment variables?
withEnv { ... }
sh
I've found that testing against the entire callStack is probably easier. https://github.com/jenkinsci/JenkinsPipelineUnit?tab=readme-ov-file#compare-the-callstack-with-a-previous-implementation
Given the following Jenkins script -
And the following unit test groovy -
Given environment variables are evaluated by the OS, and the environment variables only live within the
withEnv { ... }
block, how can these be asserted, to make sure thesh
script is running with the correct environment variables?