I’m currently struggling to implement something my team would like to have for our CI:
We would like to run a certain job only for a tag that equals a certain variable in our CI.yml.
For example and to be precise, we want to run a deploy job only for the tag
v1.0.0 when a CI variable
1.0.0. Afterwards we would like to change it so the tag
v1.0.0-rc2, etc. also runs the deploy step.
I’ve been running into a lot of problems even trying to get the basic setup working:
- I can’t seem to be able to have the
ruleskeyword even check for a variable with a leading “v”
- Trying to combat that, i was trying to define a pattern to see how that would go and it can’t even get that to work
Has anybody been doing something similar? Any pointers on how we might be able to achieve what we’re aiming at?
I’m using gitlab.com - i can link my test repository, if that is any helpful.
Add the CI configuration from
.gitlab-ci.yml and other configuration if relevant (e.g. docker-compose.yml)
This is my
variables: VERSION: "1.0.0" VERSION_REGEX: /v1\.0\.0/ stages: - prepare - deploy prepare: stage: prepare script: - echo "preparing" deploy (snapshot): stage: deploy extends: - .snapshot-job script: - echo "deploying snapshot" deploy (release): stage: deploy extends: - .release-job script: - echo "deploying release" .release-job: tags: - windows rules: - if: $CI_COMMIT_TAG && $CI_COMMIT_TAG =~ $VERSION_REGEX when: always .snapshot-job: rules: - if: $CI_COMMIT_TAG && $CI_COMMIT_TAG =~ $VERSION_REGEX when: never - when: always
What troubleshooting steps have you already taken? Can you link to any docs or other resources so we know where you have been?
I’ve mostly read through the official page Keyword reference for the .gitlab-ci.yml file | GitLab - which did not help me much for now.