Failed to trigger build: Couldn't read commit

6k views Asked by At

I work with cloud build and connect with bitbucket. The trigger have been work with a few build. But suddenly, I got the error like in the screenshot. I don't have any idea. What is it mean?enter image description here

7

There are 7 answers

1
Shawn Di Wu On

There is a limitation issue that Cloud Build connects to the bitbucket repo. it only allows the one connection per repo from Cloud Build. Please check if you have more connections to the repo? please remove the duplicate, and try again

0
Urvah Shabbir On

For me it was having regex in the branch name. So instead of ^feature/cloudbuild$ when I used feature/cloudbuild, the error did not appear.

0
rcanu On

I also got the same error:

Failed to trigger build: Couldn't read commit

I had placed a different project ID in the trigger template of when I created the trigger config .yaml file. If someone stumbles on this issue, make sure that the project ID that you have placed is the same as the project ID of the repository. See the following:

triggerTemplate:
  branchName: ^BRANCH_NAME$
  projectId: PROJECT_ID_OF_THE_SOURCE_REPO_BRANCH
  repoName: SOURCE_REPO_NAME

See documentation here:

0
Brecht Yperman On

I had the wrong repo URI (https://source.developers.google.com/$(PROJECT)/$(REPO) instead of https://source.developers.google.com/p/$(PROJECT)/r/$(REPO))

I found the problem by recreating the trigger manually and comparing the exports

gcloud alpha builds triggers export $(TRIGGERNAME) --destination=trigger.yaml
0
Christopher Suarez On

Try enabling cloud build api (Service: cloudbuild.googleapis.com) in GCP (This error occurs if you don't) this is the cloud build api: https://cloud.google.com/build/docs/api/reference/rest

Here's how to enable api's https://cloud.google.com/apis/docs/getting-started#enabling_apis

0
Vítor Resende On

I had the same error and in my case there was an error syncing the Bitbucket with Cloud Repositories.

So, I recommend you to check your Cloud Repositories inside GCP because we create a mirror there from an external Git (Bitbucket for example) and it can fail syncing.

In my case, I removed the repository and added it again and it worked.

0
Daniel On

I have also observed the same error (Couldn't read commit). The solution was updating the cloud build service account permissions.

First, we must identify the service account used in Cloud build by navigating to Cloud build -> Setting. We can then add the required permissions to the SA in IAM section. In my case, the Cloud build editor role was missing from the SA account.

Please note that this is the Cloud build Service account, not the SA used in triggers.