Conditions
Conditions limit pipeline step execution at runtime. Harness Open Source sets variables that can be used in conditions.
The following operators are supported:
Comparison
==, !=
Logical
not, and, or
Regex
matches
String
contains, startsWith, endsWith
The following functions are supported:
Always
always()
Failure
failure()
This pipeline runs the test step only for pull request events where the target branch is main.
kind: pipeline
spec:
stages:
- type: ci
spec:
steps:
- name: test
type: run
when: |
build.event == "pull_request"
and
build.target == "main"
spec:
container: ruby
script: |-
bundle install --jobs=3 --retry=3
rakeThis condition runs the step for pull request events where the target branch is not main.
This condition runs the step only when a pull request is created based on the action.
Branch
Limit execution based on the target branch.
This pipeline runs the build step when the target branch is main, or starts with feature/.
This condition uses a regular expression to achieve the same behavior.
Event
Limit execution based on the event.
This pipeline runs the clean cache step only for manually triggered pipelines.
Reference
Limit execution based on the git reference.
This pipeline runs the build step for branch names that start with feature-, or for tags.
Status
Limit execution based on the pipeline status.
This pipeline runs the notify step only when the test step fails.
This condition will always run the step.
Last updated
Was this helpful?