Reputation: 8314
For a Python project hosted on GitLab, I have a CI build configured as shown below. For every push, the CI build runs a test suite, style checks, and builds the documentation. When branches are merged to master, the CI build performs and extra step to push the built docs to GitLab Page's hosting site.
I would like to configure another job only to be executed on release candidates—git tags that include rc
in the name. The GitLab CI reference docs include several references to if: $CI_COMMIT_TAG
, but I'm struggling to understand how to put it all together.
before_script:
- apt-get update -qy
- apt-get install -y ...
- pip3 install ...
- pip3 install --no-deps --ignore-installed .
test:
stage: test
script:
- make test
- make style
- make doc
pages:
stage: deploy
script:
- apt-get update -qy
- apt-get install -y ...
- pip3 install ...
- pip3 install --no-deps --ignore-installed .
- sphinx-build -b html docs/ public
artifacts:
paths:
- public
only:
- master
UPDATE/SOLUTION
Based on the answer from @danielnelz I was able to come up with the following working solution.
before_script:
- apt-get update -qy
- apt-get install -y ...
- pip3 install ...
- pip3 install --no-deps --ignore-installed .
test:
stage: test
script:
- make test
- make style
- make doc
prerelease:
stage: test
rules:
- if: '$CI_COMMIT_TAG =~ /rc/'
script:
- make testrc
pages:
stage: deploy
script:
- sphinx-build -b html docs/ public
artifacts:
paths:
- public
only:
- master
Upvotes: 0
Views: 1124
Reputation: 5154
You can check if the predefined $CI_COMMIT_TAG
contains rc in a rules clause:
release:
stage: release
script:
- do release
rules:
- if: '$CI_COMMIT_TAG =~ /rc/'
Upvotes: 2