Reputation: 5452
I run pipeline from a tag (let's say v1.0.0
) on a branch (let's say staging
).
My output file is created with ${CI_PROJECT_NAME}-${CI_COMMIT_REF_NAME}.apk
.
The result is a file named MyProject-v1.0.0.apk
.
I wish add branch name in the output filename to get MyProject-staging-v1.0.0.apk
.
From the gitlab documentation, i could use CI_COMMIT_TAG
and CI_COMMIT_BRANCH
like this ${CI_PROJECT_NAME}-${CI_COMMIT_BRANCH}-${CI_COMMIT_TAG}.apk
.
But the documentation says:
CI_COMMIT_BRANCH : The commit branch name. Present only when building branches.
CI_COMMIT_TAG : The commit tag name. Present only when building tags.
So how to get the branch name?
Upvotes: 10
Views: 12856
Reputation: 1
There is an env var called which references either the branch name or tag name called CI_COMMIT_REF_NAME
Upvotes: -5
Reputation: 1324278
You can find which branch a tag is part of.
The issue is: a tag can be referenced (part of the history of) multiple branch.
So, as in here, your gitlab.yml
could call a script setting that branch (settings an environment variable), provided you have a convention in place to select the branch you want out of the (possibly) more than one branch which could refer said tag.
Upvotes: 8