What Is CI_COMMIT_SHA?
CI_COMMIT_SHA is the 40-character SHA of the commit that started the GitLab CI pipeline.
GitLab exposes the triggering commit as CI_COMMIT_SHA so jobs can tag images, label artifacts, or report status against the exact code under test.
Using it
Tag a build with the short SHA via CI_COMMIT_SHORT_SHA, or use the full value for precise traceability.
shell
docker build -t app:${CI_COMMIT_SHORT_SHA} .Key takeaways
- CI_COMMIT_SHA is the triggering commit hash.
- CI_COMMIT_SHORT_SHA is the abbreviated form.
- Use it to tag traceable artifacts.