View build results
This page explains how to view information about your Cloud Build builds using the Google Cloud console, the gcloud
command-line tool, and the Cloud Build API.
Before you begin
If you want to use the command-line examples in this guide, install the gcloud
command-line tool.
View build results
To view build logs, principals require one of the following IAM roles in addition to the Cloud Build IAM permissions:
If your build logs are in the default Cloud Storage bucket, grant the Project > Viewer role.
If your builds logs are in a user-specified Cloud Storage bucket, grant the Storage Object Viewer role.
For more information about the necessary permissions to view build logs in Cloud Build or GitHub or GitHub Enterprise following trigger creation, see Viewing build logs.
In the Google Cloud console, the Build History menu can show you information about a build's status (such as success or failure), source, results, create time, images, and more.
To view the Build History menu, open the Build History page in the Google Cloud console:
The Build history page is displayed, which shows a list of your recent builds.
To filter builds by region, use the Region drop-down menu at the top of the page to choose the region you would like to filter by.
You can also filter builds using the Filter builds text box at the top of the page, or by entering a query manually.
To view additional columns such as Trigger description and Artifacts, use the column selector .
To view details about a specific build, go the Build History and click on a specified build. The Build details page is displayed, with the Build Summary for your build. The Build Summary includes:
- Build Log, the log of your build.
- Execution Details, the details of your build including your environment variables and substitutions.
- Build Artifacts, the artifacts of your build such as container images, build logs, or binaries.
You can view the build log or execution details specific to a build step by selecting the step in the Steps table to the left.
Step status and build status
After a build completes, Cloud Build provides an overall status
for the build and a status
for each individual build step.
The following table summarizes the statuses when a build or a step succeeds, times out, or fails:
Event | Build Status | Step Status |
---|---|---|
Build succeeds | SUCCESS | All steps are marked SUCCESS . |
Build succeeds with failed steps permitted | SUCCESS |
|
Build fails | FAILURE |
|
Build is cancelled by the user | CANCELLED |
|
Build times out | TIMEOUT |
|
Step times out | FAILED |
|
To view per-step and build status, run the gcloud builds describe
command:
where [BUILD_ID] is the ID of the build.
The following snippet shows the per-step status from a build with a timed-out step:
Filter build results by using queries
To find information for builds that fit specific criteria, supply a query string in the Filter Builds field in the Build history page in Google Cloud console. For example, you can query for builds that have failed (that have a FAILURE
value in the status field), builds that were created after a certain time, tagged builds, and other such conditions.
Supported fields for queries
You can query for builds based on the values of the following fields:
status
build_id
trigger_id
source.storage_source.bucket
source.storage_source.object
source.repo_source.repo_name
source.repo_source.branch_name
source.repo_source.tag_name
source.repo_source.commit_sha
source_provenance.resolved_repo_source.commit_sha
results.images.name
results.images.digest
options.requested_verify_option
tags
images
create_time
start_time
finish_time
Fields listed with dot notation (.
) are subfields.
Constructing a query string
Query strings use the general form:
Use dot notation to specify a subfield, such as results.images.name
. Queries support the =
and !=
comparison operators, as well as >
, >=
, <
, and <=
for fields that have numeric values (such as create_time
).
You can create compound queries by using the boolean AND
and OR
expressions.
Common example queries
To query for all successful builds:
To query for all builds that have yet to finish:
To query for builds with a given result image name:
To query for all builds with the tag "prod"
:
To query for builds marked as verified:
To query for builds that come from a source in Cloud Storage (as opposed to a Cloud Source Repository):
To query for builds with a given result digest:
To query for builds started after a specific time and finished before a specific time (UTC timezone):
Filter build results by using tags
You can use tags in your config files, which allows you to organize your builds into groups and to filter your builds. You can specify strings in tags, such as "prod"
or "test"
.
Tags have the following limitations:
- Each tag's character limit is 128 characters
- You can define a maximum of 64 tags per build
- Tags can contain letters, numbers, and underscores in any position of your string.
- Tags can contain periods and hyphens in any position except the first position of your string.
To add tags in your build:
In your build config file, add the
tags
field:To see tagged builds in your cluster, use the
--filter
option ingcloud builds list
. You can filter builds by specifying a single tag or multiple tags.To filter builds by a single tag, specify the tag as a string in the
tags
field. The following command lists all builds tagged with'test1'
:To filter builds by multiple tags, use "AND", "OR", or "NOT" to list tags. The following command lists all builds tagged with
'test1'
or'test2'
and tagged with'test3'
:
You will see an output similar to the following after running these commands:
Comments
Post a Comment