Interview Prep/Jenkins/Scripted pipeline, Groovy & CPS

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'.

All Jenkins questions Roadmap: Jenkins

More on Scripted pipeline, Groovy & CPS