Environment variables and parameters

Jenkins CI/CD Course · lesson 6 of 15 · 5 min read

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 hub

Key points

  • Every build gets BUILD_NUMBER, JOB_NAME, WORKSPACE and BUILD_URL in the environment.
  • Multibranch adds BRANCH_NAME, and pull request builds also carry CHANGE_ID and CHANGE_TARGET.
  • An environment block inside a stage overrides the pipeline level value for that stage only.
  • Parameters are read as params.NAME, and a booleanParam arrives as a real boolean, not a string.
  • Adding a parameters block takes effect only after one build has run and registered the definition.
  • A choice parameter 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.