Buildkite pull request build failed for existing commits

Hi Team,

I have disabled “Skip pull request builds for existing commits” in the pipeline settings

Buildkite build triggered by commit push webhook is successful

But the Buildkite build triggered by a pull request for the same commit failed during the “Preparing working directory” step with an error

git fetch -v --prune -- origin 456b02e2af84	
fatal: couldn't find remote ref 456b02e2af84
🚨 Error: fetching commit "456b02e2af84": exit status 128


Bitbucket webhook payload for push has commit with full hash


Bitbucket webhook payload for pull request payload has a different commit hash for the same commit

"commitId": "456b02e2af84"

I had to create another dummy commit to trigger the Buildkite build to fix the pipeline.

do we have a workaround for this? Any help/suggestions would be appreciated.

Hello @sindhuja!

Hope you’re well and thanks for the question - welcome to the Buildkite Support Community!

The good news is that this has been something we have seen before with received Bitbucket webhooks containing a short SHA which Buildkite resolves to BUILDKITE_COMMIT and hence those seen checkout errors occur. In that in agent version v3.58.0 and newer - we included a fix for events like this (where BUILDKITE_COMMIT is set to a short SHA from a resultant webhook and errors are seen in the fetching process). The actual PR for the fix was described here. If you’re using an older version of the Buildkite agent than this, I’d suggest updating it to that version (or latest) to get this inclusive!

Another way that I’ve coined (transparently from the inbuilt agent resolution and from the commentary previously) is something like the below: you could potentially set the BUILDKITE_COMMIT with a git log to get the full SHA back, or potentially query the BitBucket API to list the commits and obtain the relevant full SHA from the responses’ payload (note you’ll need to export below in hooks - before the checkout phase)

export BUILDKITE_COMMIT=$(git log -1 --format="%H" $BUILDKITE_COMMIT 2>/dev/null)

Hope the above does help :slight_smile:

1 Like

Hi @james.s
Thank you for the quick reply and the suggestion with the details.

No worries @sindhuja!

Please let us know if anything else pops up :slightly_smiling_face:

Thanks @james.s upgrading to the latest Buildkite agent version solved the issue.

Excellent to hear!

Thanks for confirming the solution too :slightly_smiling_face:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.