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.

If you want to use the command-line examples in this guide, install the gcloud command-line tool.

To view build logs, principals require one of the following IAM roles in addition to the Cloud Build IAM permissions:

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:

Open the Build History page

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.

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:

EventBuild StatusStep Status
Build succeedsSUCCESSAll steps are marked SUCCESS.
Build succeeds with failed steps permittedSUCCESS
Build failsFAILURE
  • Failed step is marked FAILED.
  • Steps that succeed before the termination of the build are marked SUCCESS.
  • Steps in the middle of execution are marked CANCELLED.
  • Steps that do not start to execute are marked QUEUED.
Build is cancelled by the userCANCELLED
  • Steps that succeed before the cancellation of the build are marked SUCCESS.
  • Steps in the middle of execution are marked CANCELLED.
  • Steps that do not start to execute are marked QUEUED.
Build times outTIMEOUT
  • Steps that succeed before the build times out are marked SUCCESS.
  • Steps in the middle of execution are marked CANCELLED.
  • Steps that do not start to execute are marked QUEUED.
Step times outFAILED
  • The step that times out is marked TIMEOUT.
  • Steps that succeed prior to the timed-out step are marked SUCCESS.
  • Steps in the middle of execution are marked CANCELLED.
  • Steps that do not start to execute are marked QUEUED.

To view per-step and build status, run the gcloud builds describe command:

gcloud builds describe [BUILD_ID]

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:

status: FAILURE
steps
:
- args:
 
- sleep
 
- '60'
id
: long sleep
name
: alpine
status
: CANCELLED
timing
:
    endTime
: '2018-02-26T14:09:18.531368493Z'
    startTime
: '2018-02-26T14:09:11.023235026Z'
waitFor
:
- '-'
- args:
- sleep
- '3'
id
: shorty
name
: alpine
status
: SUCCESS
timeout
: 60s
timing
:
    endTime
: '2018-02-26T14:09:15.497724138Z'
    startTime
: '2018-02-26T14:09:11.023676903Z'
waitFor
:
- '-'
- args:
 
- sleep
 
- '60'
name
: alpine
status
: TIMEOUT
timeout
: 3s
timing
:
    endTime
: '2018-02-26T14:09:18.527488475Z'
    startTime
: '2018-02-26T14:09:15.497736775Z'
waitFor
:
- shorty
- args:
 
- 'false'
name
: alpine
status
: QUEUED
waitFor
:
- long sleep
timeout
: 60s

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:

field="value"

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:

status="SUCCESS"

To query for all builds that have yet to finish:

status="QUEUED" OR status="WORKING"

To query for builds with a given result image name:

(status="SUCCESS" OR status="FAILURE") AND \
    results
.images.name="us-east1-docker.pkg.dev/my-project/my-image"

To query for all builds with the tag "prod":

tags="prod"

To query for builds marked as verified:

options.requested_verify_option="VERIFIED"

To query for builds that come from a source in Cloud Storage (as opposed to a Cloud Source Repository):

source.storage_source.bucket!=""

To query for builds with a given result digest:

results.images.digest="sha256:6c7147fe4c813845ac2a9aa6f937bb272b68784f647c4f64c7325723c7245c88"

To query for builds started after a specific time and finished before a specific time (UTC timezone):

create_time>"2016-10-12T18:43:49+00:00" AND finish_time<"2016-10-13T18:43:49+00:00"

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:

  1. In your build config file, add the tags field:

    steps:
    - name: 'gcr.io/cloud-builders/docker'
      args
    : [ 'build', '-t', 'us-east1-docker.pkg.dev/$PROJECT_ID/cb-demo-img', '.' ]
    images
    :
    - 'us-east1-docker.pkg.dev/$PROJECT_ID/cb-demo-img'
    tags
    :
    - 'test1'
    - 'test2'
  2. To see tagged builds in your cluster, use the --filter option in gcloud 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':

       gcloud builds list --filter "tags='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':

       gcloud builds list --filter "tags=('test1' OR 'test2') AND 'test3'"

    You will see an output similar to the following after running these commands:

    ID                                    CREATE_TIME                DURATION  SOURCE                                                                             IMAGES                                 STATUS
    d33a9895
    -...                          ...                        1M45S     gs://...                                                                           us-east1-docker.pkg.dev/...            SUCCESS

Comments

Popular posts from this blog

Terraform

Different Types of Reports in Scrum - Agile

Scrum Master Interview help - Bootcamp