3

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

Uysim Ty
  • 131
  • 2
  • 5
  • Cloud Build could not detect the commit. Can you confirm if you can observe the commits in your bitbucket branch ? How did you trigger the build? – Shawn Di Wu Sep 07 '20 at 18:44
  • I did it both push the mater branch and trigger it manually by button in the console. Also, I see the git master branch and commit number in the source repo correctly. – Uysim Ty Sep 08 '20 at 03:29
  • 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, let me know. I will continue researching the explanation of this issue. – Shawn Di Wu Sep 09 '20 at 05:23
  • @ShawnDiWu I have two repo. Backend and Frontend. But it is different repository. Is there the issue with this kind of connection too? – Uysim Ty Sep 09 '20 at 05:37
  • Exactly! that is the issue, keep[ with one repo! I will try to find documentation explaining this and post the answer here. – Shawn Di Wu Sep 09 '20 at 05:45
  • I believe you encountered the same situation as [this case](https://stackoverflow.com/questions/50575102/google-cloud-container-builder-not-always-triggering-from-bitbucket) – Shawn Di Wu Sep 10 '20 at 06:30

6 Answers6

1

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:

rcanu
  • 23
  • 6
1

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.

Urvah Shabbir
  • 945
  • 2
  • 15
  • 46
1

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
Brecht Yperman
  • 1,209
  • 13
  • 27
0

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

Shawn Di Wu
  • 460
  • 2
  • 9
0

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

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.

Daniel
  • 1
  • 2