How to get branch name when running pipeline on tag?

Viewed 3260

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?

2 Answers

There is an env var called which references either the branch name or tag name called CI_COMMIT_REF_NAME

Related