There's a part of the script which I want to run only if it's a tag pipeline. How do I represent that as a condition?
CodePudding user response:
You can use rules or the only keyword to run only on tags or merge requests.
rules:
job1:
script:
- echo "This job runs in merge request pipelines"
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
only:
job1:
script:
- echo "This job runs in merge request pipelines"
only:
- merge_requests
To run only on tags you can use:
job1:
script:
- echo "This job runs only on tags"
only:
- tags
Docs: https://docs.gitlab.com/ee/ci/yaml/#onlyrefs--exceptrefs
