patternMinor
Jenkins UUIDs ... oh the humanity
Viewed 0 times
jenkinstheuuidshumanity
Problem
I have an environment block
When I use SMOKE_CMD and FAILED_TESTS in their respective stages I get different UUIDs... why?
environment {
SUITE_RUN_ID = UUID.randomUUID().toString()
SMOKE_CMD = "runtests.sh SUITE_RUN_ID=${SUITE_RUN_ID}"
FAILED_TESTS = "output_rerun_info.rb SUITE_RUN_ID=${SUITE_RUN_ID}"
}When I use SMOKE_CMD and FAILED_TESTS in their respective stages I get different UUIDs... why?
Solution
The block needs to be resolved for each stage, otherwise you could not use stage dependent methods in the block, so there would need to be some check on what methods to use and what to not use, it would lead to even more problems. Further each stage can be executed on different node, so the code needs to re-resolve it. Otherwise it would just behave differently with single node or in parallel. Just deal with it.
Instead of setting the variables in the environment block, simply set them in the first stage. And in the agent set the
Instead of setting the variables in the environment block, simply set them in the first stage. And in the agent set the
reuseNode true.Context
StackExchange DevOps Q#4663, answer score: 4
Revisions (0)
No revisions yet.