Reputation: 127
I am working on project where according to sprint release branch, dynamic branch get created every week. like release/XXXX.XX (example: release/2021.01) and I am using specific tag to trigger the Gitlab pipeline as well.
How can I call this dynamic branch name into Gitlab CI. So far what I have tried is.
- $CI_COMMIT_MESSAGE ==> which will accept the data from variable when any
commit the message as "release/2021.01" while pushing the code and will do next sets of operation like merge.
Its working though but not acceptable because each commit should have specific description about changes we are making.
- $CI_COMMIT_TAG ==> which will use last tag applied against the sprint release branch
(which actually also a trigger for pipeline) and do the next operation like merge. But this also not acceptable
and then
- CI_COMMIT_REF_NAME ==> which also works but its fetch the last tag applied against the sprint release branch but do not fetch exact release/2021.01 branch.
**Edit 1:**
Every week, sprint release branch get created by developer team manually. this changed branch name i wanted to call in variable within the job.
Dev Team will create a tag against the release/2021.01 branch which will add the jobs in pipeline.
In one of my job, I wanted to call this dynamic branch name and perform next set of operations. i do not wanted to know what number of sprint release branch Dev has created.
just there should be method using which i can pick the branch name against which tag was deployed.
Upvotes: 0
Views: 1535
Reputation: 40891
- $CI_COMMIT_MESSAGE ==> which will accept the data from variable when any commit the message [...] Its working though but not acceptable because each commit should have specific description about changes we are making.
Instead of using the commit message, you can use git push options to set CI/CD variables:
git push -o ci.variable="RELEASE_BRANCH=release/2021.01"
You can also set variables when triggering pipelines manually or on a schedule, or in the project CI/CD settings.
For example, perhaps when your sprint begins, in addition to creating your sprint branch, you can also change the variable in the project settings.
If you just want the current branch name, it's held in $CI_COMMIT_BRANCH
.
Upvotes: 1