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 conditional expressions and manual approvals

Use conditional expressions and manual approvals

When you're developing pipelines, you might need to use logic to determine if a stage should run or not. You also might need to use manual interaction to approve an automated process. Jenkins exposes these two capabilities with conditionals and manual approvals. We can configure conditions based on branches, environment variables, and expressions. And we can use input from the user interface to pause operations. To set up a pipeline condition, we use the when keyword inside of a stage block. 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 you to only run stages for specific branches in a repo. Environment conditions return true only when the given environment variable is present and matches a required value. This lets you trigger stages based on specific settings in the build environment…

Contents