Environment variables and parameters
Jenkins injects a fixed set of variables, and parameters are how a human or another job varies a run.
Open this lesson in the learning hubKey points
- Every build gets
BUILD_NUMBER,JOB_NAME,WORKSPACEandBUILD_URLin the environment. - Multibranch adds
BRANCH_NAME, and pull request builds also carryCHANGE_IDandCHANGE_TARGET. - An
environmentblock inside a stage overrides the pipeline level value for that stage only. - Parameters are read as
params.NAME, and abooleanParamarrives as a real boolean, not a string. - Adding a
parametersblock takes effect only after one build has run and registered the definition. - A
choiceparameter defaults to its first entry, so put the safe value at the top of the list.
Parameters vary a run, environment shares values across stages, and both register only after the first build.
This is a reading copy. The full lesson — with the visual explainer, the interactive lab and a Run button for the code — lives in the Jenkins CI/CD Course course, and every lesson in it is listed on the Jenkins CI/CD Course contents page.