Is there any unique number in Gitlab CI which can be used as build number as we use in Jenkins. I came to know about the variable "CI_PIPELINE_IID" but the problem with this variable is, it updates for all branches and there is no such variable exist for each branch.
We solved the same issue using the variable $CI_PIPELINE_IID
, which is defined as
The project-level IID (internal ID) of the current pipeline. This ID is unique only within the current project.
And is quite similar to Jenkins' $BUILD_NUMBER
See also https://docs.gitlab.com/ee/ci/variables/predefined_variables.html#variables-reference
It looks like CI_COMMIT_SHA
or CI_COMMIT_SHORT_SHA
are great candidates for this as they give you a reference to the commit it was built from.
For example, if you want to use it as a docker image tag, use
docker build . -t myapp:$CI_COMMIT_SHA
Note that earlier versions of Gitlab (version 8.x) use CI_BUILD_TAG
More variables on: https://docs.gitlab.com/ee/ci/variables/predefined_variables.html#variables-reference
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With