I made this simple job that should be triggered only for tag created on test branch.
deploy_job:
stage: manual_deploy
script:
- echo "Deploying the project...!!!"
rules:
- if: '$CI_COMMIT_TAG && $CI_COMMIT_REF_NAME == "test"'
when: manual # This makes the job manual
but when I create the tag by Gitlab UI , and I print the value of $CI_COMMIT_REF_NAME
it takes the value of the tag and the job does not trigger (in this case being manual should appear the button on pipeline page to start it, but it does not appear). How can I verify the name of the branch where the tag has been pushed?
I imagine you have a branch called test
According to the gitlab docs : https://docs.gitlab.com/ee/ci/variables/predefined_variables.html
The variable CI_COMMIT_REF_NAME
is "The branch or tag name for which project is built."
It is expected behavior and you have to keep in mind that tags aren't linked to any branch, it is a git reference to a commit (and a commit can be in multiple branches.. that's why the variable CI_COMMIT_BRANCH
is not available on tags pipelines), maybe you can do your workflow a bit differently or maybe you don't need to tag (or you can use a regex to only do your job on certain tags that follow a pattern)