Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Build triggers UI question

I'm getting an error that is mentioned a few times here, however I am using the option in the UI to use a Dockerfile. The configuration options are use a cloudbuild file OR a Dockerfile. Does this not actually work? I would expect the build trigger to use my Dockerfile when running, but it seems to be looking for cloudbuild instructions which don't exist.

The error I'm getting is the following:
Your build failed to run: generic::invalid_argument: if 'build.service_account' is specified, the build must either (a) specify 'build.logs_bucket', (b) use the REGIONAL_USER_OWNED_BUCKET build.options.default_logs_bucket_behavior option, or (c) use either CLOUD_LOGGING_ONLY / NONE logging options

However, I am not using the Cloud Build configuration file (yaml or json) option. 

 

Solved Solved
0 4 1,032
1 ACCEPTED SOLUTION

Thanks for the response, but we just ended up moving back to github actions.

View solution in original post

4 REPLIES 4

Hi @katris,

Welcome to Google Cloud Community!

It seems that the service account you are using for Cloud Build doesn't have the right permissions. Confirm that the builder service account has the roles/logging.admin role to store build logs and use all of the actions in Logging. 

The builder service account must also have access to create and write to Cloud Storage buckets in the build project. Grant the roles/compute.storageAdmin role to your service account. 

You can also view your build logs for each individual build step and overall status

I hope the above information is helpful.

The service has the mentioned roles but the trigger can't be launched as we get the same error.  Currently CloudBuild is unusable for docker files.

Failed to trigger build: generic::invalid_argument: if 'build.service_account' is specified, the build must either (a) specify 'build.logs_bucket', (b) use the REGIONAL_USER_OWNED_BUCKET build.options.default_logs_bucket_behavior option, or (c) use either CLOUD_LOGGING_ONLY / NONE logging options

It sounds like you're running into an issue with your Cloud Build trigger configuration, katris. Even though you've selected to use a Dockerfile in the UI, the error message suggests Cloud Build is expecting a cloudbuild.yaml file and specific logging settings. This can happen due to a few reasons:
 
1. Trigger Settings Mismatch: Double-check your trigger settings. Ensure the "Build Configuration" is set to "Dockerfile" and that you've specified the correct Dockerfile path. Sometimes a hidden setting might override the UI selection.
 
2. Service Account Permissions: The error mentions build_service_account. Make sure the service account used by your trigger has the necessary permissions to write logs to Cloud Storage. It might need permissions like storage.objects.create if it's supposed to create a new bucket or storage.objects.write if it's writing to an existing one.
 
3. Regional Considerations: The error also mentions REGIONAL_USER_OWNED_BUCKET. If you're using a custom bucket for logs, ensure it's in the same region as your Cloud Build trigger.
 
4. Hidden cloudbuild.yaml: Is there a chance a cloudbuild.yaml file exists in your repository that you're unaware of? Cloud Build might be picking it up automatically. Try searching your repository for this file.
 
To troubleshoot further:
 
Examine the Trigger Details: Carefully review all the settings in your trigger configuration in the Cloud Build UI. Look for any inconsistencies or unexpected configurations.
 
Test with a Minimal Dockerfile: Create a very simple Dockerfile (e.g., FROM ubuntu:latest) to rule out any issues within your Dockerfile itself.
 
Manual Build: Try running a manual build using gcloud builds submit --config [Dockerfile path] from your repository's root directory. This can help isolate if the issue is specifically with the trigger or with the build process itself.
 
If you're still stuck, providing the following information might help in giving more specific guidance:
 
Trigger settings screenshot: A screenshot of your trigger configuration in the Cloud Build UI.
 
Relevant parts of your Dockerfile: The initial lines of your Dockerfile.
 
Project ID and Region: Your Google Cloud project ID and the region where you're running Cloud Build.
 
I'm here to help you get this sorted out! Let me know if you have any more details to share.

Thanks for the response, but we just ended up moving back to github actions.