I am having trouble with build not being triggered by Cloud build.
I created a trigger according to the URL below, but I am using my repository(Github), not the sample repository.
https://cloud.google.com/build/docs/automate-builds
So, I have tried two patterns of cloudbuild.yaml.
Pattern 1 is triggered and an error is displayed. Pattern 2 is not triggered and no error is displayed.
Why is pattern 2 not triggered?
◆Pattern 1
○cloudbuild.yaml
steps:
- name: 'gcr.io/cloud-builders/docker'
args: [ 'build', '-t', '{IMAGE_NAME}', '.' ]
- name: 'gcr.io/cloud-builders/docker'
args: ['push', '{IMAGE_NAME}']
○Build history
ビルドを実行できませんでした: generic::invalid_argument: if 'build.service_account' is specified, the build must either (a) specify 'build.logs_bucket' (b) use the CLOUD_LOGGING_ONLY logging option, or (c) use the NONE logging option
◆Pattern 2
○cloudbuild.yaml
I have added a logsBucket setting.
steps:
- name: 'gcr.io/cloud-builders/docker'
args: [ 'build', '-t', '{IMAGE_NAME}', '.' ]
- name: 'gcr.io/cloud-builders/docker'
args: ['push', '{IMAGE_NAME}']
logsBucket: 'gs://{BUCKET_NAME}'
○Build history
The build history does not even show a history of running or error status.
Nothing was output to the specified log bucket either.
Therefore, I believe that the build is not triggered.
Checking Github, the following message appears and it seems to be accumulating in the queue.
“Some checks haven’t completed yet”
Hi @YoshinaoMori ,
Welcome to Google Cloud Community!
When running builds, Cloud Build collects and stores your build logs. From this documentation,
By default, Cloud Build stores your build logs in a Google-created Cloud Storage bucket. You can view build logs stored in the Google-created Cloud Storage bucket, but you cannot make any other changes to it. If you require full control over your logs bucket, store the logs in a user-created Cloud Storage bucket.
You may try to do the following steps to solve the problem:
- According to the error you’re getting, you have to add the log specification at the end of your YAML file, make sure that the IAM API is enabled. See documentation.
options:
logging: CLOUD_LOGGING_ONLY
-
Are your Cloud Storage Bucket and Cloud Build in the same Google Cloud Project? Are you using a user-specified service account? If yes, you’d have to grant Storage Admin role to the service account, check Granting roles on the project. However if you’re not using any user-specified service account , by default, Cloud Build service account will be used, and it has already the necessary IAM permissions so you do not need to grant additional permissions.
-
If your Cloud Build and Storage Bucket are in different projects, you have to grant Storage Admin role to the Cloud Build service account. See more information, here.
-
For the pattern 2 try to add,
options:
logging: GCS_ONLY
Let me know if these worked.
anjelisa-san
Thanks for the quick response!
2. Are you using a user-specified service account? If yes, you'd have to grant Storage Admin role to the service account, check Granting roles on the project. However if you're not using any user-specified service account , by default, Cloud Build service account will be used, and it has already the necessary IAM permissions so you do not need to grant additional permissions.
I used the above as a reference and switched to the default service account and it worked.
@anjelisa Hi
I have similar situation but I need to use custom SA. I created a service account in same project where trigger is created and added storage admin role to it. also in my cloudbuild.yaml I added
logsBucket: 'gs://cloud-build-logs-sandbox-10fb8'
options:
logging: GCS_ONLY
but trigger still not working. and I am sure it’s not related to any other trigger configuration cause if I switched to default SA, it works.
any idea?
the last line is the hint. for your custom SA, the access at some places is missing. Here I think, STorage Object Owner and Storage Owner to start with. Also, ensure that bucket name exists in GCS