Hello I have a scheduled pipeline that runs on the main
branch on Gitlab. I don’t want it to run on tags
I tried adding:
rules:
- if: "$CI_COMMIT_TAG"
when: never
- if: '$CI_PIPELINE_SOURCE == "schedule" && $SCHEDULE_TASK == "daily"'
but it still seems to run on tags.
Any idea how I can skip the pipeline on tags?
In Build > Pipeline Schedules
, you can set the target branch or tag for being executed on. If you want to execute on both, you can set variables. For example, you can create 2 scheduled pipelines (One for a tag and one for main branch), then for each in the Variables section, assign a variable name with different values. For example, we set
Main scheduled pipeline -> Target Branch: main, Variables: SCHEDULED_TARGET=main
Tag scheduled pipeline -> Target Branch: sometag, Variables: SCHEDULED_TARGET=tag
and in the .gitlab-ci.yml
for the scheduled pipeline of main branch:
rules:
- if: '$CI_PIPELINE_SOURCE == "schedule" && $SCHEDULE_TASK == "daily" && $SCHEDULED_TARGET == "main"'
you may have the same for the scheduled pipeline of tag:
rules:
- if: '$CI_PIPELINE_SOURCE == "schedule" && $SCHEDULE_TASK == "daily" && $SCHEDULED_TARGET == "sometag"'