When Condition
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
when:
equal:
- << status.build.package >>
- success
when-not-equal
when-not-equal
not-equal:
- << status.build.package >>
- failed
when-not
when:
-not:true
when-and/when-or
when:
or:
- and:
- equal:
- << pipeline.status.build >>
- success
- not-equal:
- << pipeline.status.build.hello-world >>
- failed
- equal:
- << pipeline.event.{{Event Variable Placeholder}} >>
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:
pipeline-when:
equal:
- << event.ref >>
- refs/heads/main
Last Updated 2025-05-30 16:54:59 +0530 IST
Yes
No
Send your feedback to us