gitlab CI rules: dynamic $CI_COMMIT_PREV_HASH returns unexpected value
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
$CI_COMMIT_BEFORE_SHA is returning an unknown value that is NOT my previous commit hash value. This issue occurs when pushing a commit to a feature branch:
I am pushing to a feature branch, not yet an MR, and want to only trigger a rebuild job if my new commit contains a Dockerfile diff compared to my previous commit.
utilizing compare_to: $CI_COMMIT_BEFORE_SHA dynamically does not trigger this rule:
- if: $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH
changes:
paths:
- .gitlab/Dockerfile
compare_to: $CI_COMMIT_BEFORE_SHA
however, by merely hardcoding my previous commit hash value, compare_to: abc123abc12 it now triggers the rule.
- if: $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH
changes:
paths:
- .gitlab/Dockerfile
compare_to: abc123abc12
$CI_COMMIT_BEFORE_SHA is clearly returning an unknown, incorrect value that is not my previous commit hash.
Edited by 🤖 GitLab Bot 🤖