From the course: Jenkins Essential Training

Unlock the full course today

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

Use conditional expressions and manual approvals

Use conditional expressions and manual approvals - Jenkins Tutorial

From the course: Jenkins Essential Training

Use conditional expressions and manual approvals

- [Instructor] When we're developing pipelines we might need to use logic to determine if a stage should be run or not. We might also need to add some sort of manual interaction to an automated process. Let's discuss how Jenkins exposes these two capabilities in a pipeline configuration. To set up a pipeline condition, we use the when keyword inside a stage block. The when block uses three built in conditions to determine if the steps in a stage should be run. The conditions are branch, environment, and expression. If the specified condition evaluates to true, then the stage will be allowed to run, otherwise the stage will be skipped. Branch conditions are useful when the pipeline is interacting with a version control system like GitHub. This allows us to only run stages for specific branches in a repo. Environment conditions evaluate to true, if the specified environment variable is present and it contains the specified…

Contents