Reputation: 139
I use maven-release-plugin
to create releases of my applications. I have a Gitlab CI Component to do so and that works as expected. Additionally I have a Gitlab CI Component that gets the changelog from the Gitlab API and creates a release page in Gitlab. These are two jobs, each of which have the following rule:
rules:
- if: $CI_COMMIT_TAG
Now, maven-release-plugin
creates a git tag and pushes it to the repository. I would like to use this event and trigger a new pipeline to create the release page with the changelog. My expectation was that when maven-release-plugin
pushes the release tag, Gitlab would create a new pipeline with the two jobs that fetch the changelog and create the release page. However, this is not happening, nothing happens.
What am I missing?
Upvotes: 0
Views: 39
Reputation: 1019
Simple configuration that produce pipeline that runs for tags only:
build:
stage: build
script:
- echo "Hello, $GITLAB_USER_LOGIN!"
deploy:
stage: deploy
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
script:
- echo "Deploy the app"
release:
stage: deploy
rules:
- if: $CI_COMMIT_TAG
script:
- echo "Release the tag"
You can see in my build history, two pipelines:
This is the part that could be confusion: the same commit is built twice, and if you push branch & tag at the same time, you could expect it to be all done in the same pipeline. Since tags can be added at any time to any commit, it makes sense that GitLab creates a separate pipeline for it. It brings some limitations though: if you try to combine the tag-related rules, with variables related to merge requests or file changes, you will get a job that is never run. Which sounds similar to your case.
Another option, is that the tag is never pushed. You can double-check the tags on the analogous page to this one: https://gitlab.com/how-to-dev/tag-jobs/-/tags
If your tag is not there, it means you failed to push it to GitLab. I got my tag with the following commands:
git tag v1.0 # create tag localy
git push origin v1.0 # push tag to GitLab
Upvotes: 0