When Condition

Introduction

The when condition is a basic logic that can be configured to define the execution flow of the pipeline. You can define the when condition at the stage level, job level, or the pipeline level. It is important to note that the when condition can be applied at any of these levels, and the order of the components is not significant.

The following operators can be used along with the when condition:

when-equal

    
copy
when: equal: - << status.build.package >> - success when-not-equal

when-not-equal

    
copy
not-equal: - << status.build.package >> - failed

when-not

    
copy
when: -not:true

when-and/when-or

    
copy
when: or: - and: - equal: - << pipeline.status.build >> - success - not-equal: - << pipeline.status.build.hello-world >> - failed - equal: - << pipeline.event.{{Event Variable Placeholder}} >>
Note: You will not be able to configure when conditions for approval jobs.

Global Configuration

You can define a when condition at the pipeline level, if required. This condition solely determines the pipeline execution flow. You can configure the condition as follows:

    
copy
pipeline-when: equal: - << event.ref >> - refs/heads/main

Last Updated 2025-05-30 16:54:59 +0530 +0530