What is the difference between `env.X`, `params.X` and plain variables?
BeginnerConceptScripted pipeline, Groovy & CPS
Answer
params.X is a read-only map of build parameters with their real types (boolean stays boolean). env.X is the environment of the build; values are strings, so env.RUN_E2E == 'true' not true. Parameters are also copied into env. Plain Groovy variables live only in the script and are not visible to sh unless you pass them in. A common bug is if (env.DEBUG) being true for the string 'false'.
More on Scripted pipeline, Groovy & CPS
What does a scripted pipeline look like and when would you still write one?IntermediateWhat is CPS and why does Jenkins transform pipeline Groovy?AdvancedWhy does `java.io.NotSerializableException` happen in pipelines?AdvancedWhat does `@NonCPS` do and what are its rules?AdvancedWhy do some Groovy closures behave unexpectedly in pipelines, for example `list.each { }` or `sort`?AdvancedWhat is the `script` block in declarative, and what are its limits?Beginner