From the course: Intermediate Jenkins: Automate, Integrate, and Secure CI/CD Workflows at Scale

Unlock this course with a free trial

Join today to access over 25,200 courses taught by industry experts.

Use variables in a pipeline

Use variables in a pipeline

Variables let us use dynamic values in our pipelines. The most common types of pipeline variables are environment variables and parameters. For now, we'll focus on environment variables. We'll use another lesson to discuss parameters. The best practice for naming variables is to use all uppercase letters. This makes it easy to tell variables apart from the pipeline keywords, which are usually named using lowercase letters. Environment variables can be scoped globally for an entire pipeline, or they can be scoped locally within a stage. Using an environment block at the beginning of a pipeline exposes the variables to all pipeline steps. Using an environment block at the beginning of a stage only exposes variables to steps within that stage. This is useful if a certain stage needs to override a variable that was previously defined. Environment variables can be referenced in a few different ways depending on how they're being used. They can be preceded by the keyword env in lowercase…

Contents