I am running a ci task on my Gitlab server. One of the actions is to call an exe on the build runner machine which does some updates.
I pass through the SHA1s from $CI_COMMIT_BEFORE_SHA and $CI_COMMIT_SHA and the code calls:
git diff --name-only $CI_COMMIT_BEFORE_SHA $CI_COMMIT_SHA
Usually it gives me a list of file names which have changed in the commit but sometimes I get the error:
fatal: bad object abcd1234
^
|-- This is the $CI_COMMIT_SHA
The repo has just been downloaded to the build runner so it is up to date, why would the git diff return a bad object here?
If the commit is "old" it could be missing from the clone because Gitlab uses a shallow clone with a depth of 20 by default.
This is why you see this message in the job's log:
Fetching changes with git depth set to 20...
Possible solutions:
GIT_DEPTH from .gitlab-ci.yml.gitlab-ci.yml scriptsgit fetch origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME git diff-tree --no-commit-id --name-only -r $CI_COMMIT_BEFORE_SHA -r $CI_COMMIT_SHA
It helped me!
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