Starts a build with the specified configuration. This method returns a long-running Operation, which includes the build ID. Pass the build ID to GetBuild to determine the build status (such as SUCCESS or FAILURE).

Scopes

You will need authorization for the https://www.googleapis.com/auth/cloud-platform scope to make a valid call.

If unset, the scope for this method defaults to https://www.googleapis.com/auth/cloud-platform. You can set the scope for this method like this: cloudbuild1 --scope <scope> projects builds-create ...

Required Scalar Argument

  • <project-id> (string)
    • Required. ID of the project.

Required Request Value

The request value is a data-structure with various fields. Each field may be a simple scalar or another data-structure. In the latter case it is advised to set the field-cursor to the data-structure's field to specify values more concisely.

For example, a structure like this:

Build:
  approval:
    config:
      approval-required: boolean
    result:
      approval-time: string
      approver-account: string
      comment: string
      decision: string
      url: string
    state: string
  artifacts:
    images: [string]
    objects:
      location: string
      paths: [string]
      timing:
        end-time: string
        start-time: string
  build-trigger-id: string
  create-time: string
  failure-info:
    detail: string
    type: string
  finish-time: string
  id: string
  images: [string]
  log-url: string
  logs-bucket: string
  name: string
  options:
    automap-substitutions: boolean
    default-logs-bucket-behavior: string
    disk-size-gb: string
    dynamic-substitutions: boolean
    env: [string]
    log-streaming-option: string
    logging: string
    machine-type: string
    pool:
      name: string
    requested-verify-option: string
    secret-env: [string]
    source-provenance-hash: [string]
    substitution-option: string
    worker-pool: string
  project-id: string
  queue-ttl: string
  results:
    artifact-manifest: string
    artifact-timing:
      end-time: string
      start-time: string
    build-step-images: [string]
    build-step-outputs: [string]
    num-artifacts: string
  service-account: string
  source:
    connected-repository:
      dir: string
      repository: string
      revision: string
    git-source:
      dir: string
      revision: string
      url: string
    repo-source:
      branch-name: string
      commit-sha: string
      dir: string
      invert-regex: boolean
      project-id: string
      repo-name: string
      substitutions: { string: string }
      tag-name: string
    storage-source:
      bucket: string
      generation: string
      object: string
      source-fetcher: string
    storage-source-manifest:
      bucket: string
      generation: string
      object: string
  source-provenance:
    resolved-connected-repository:
      dir: string
      repository: string
      revision: string
    resolved-git-source:
      dir: string
      revision: string
      url: string
    resolved-repo-source:
      branch-name: string
      commit-sha: string
      dir: string
      invert-regex: boolean
      project-id: string
      repo-name: string
      substitutions: { string: string }
      tag-name: string
    resolved-storage-source:
      bucket: string
      generation: string
      object: string
      source-fetcher: string
    resolved-storage-source-manifest:
      bucket: string
      generation: string
      object: string
  start-time: string
  status: string
  status-detail: string
  substitutions: { string: string }
  tags: [string]
  timeout: string

can be set completely with the following arguments which are assumed to be executed in the given order. Note how the cursor position is adjusted to the respective structures, allowing simple field names to be used most of the time.

  • -r .approval.config approval-required=true

    • Whether or not approval is needed. If this is set on a build, it will become pending when created, and will need to be explicitly approved to start.
  • ..result approval-time=gubergren

    • Output only. The time when the approval decision was made.
  • approver-account=eos
    • Output only. Email of the user that called the ApproveBuild API to approve or reject a build at the time that the API was called.
  • comment=dolor
    • Optional. An optional comment for this manual approval result.
  • decision=ea
    • Required. The decision of this manual approval.
  • url=ipsum

    • Optional. An optional URL tied to this manual approval result. This field is essentially the same as comment, except that it will be rendered by the UI differently. An example use case is a link to an external job that approved this Build.
  • .. state=invidunt

    • Output only. The state of this build's approval.
  • ..artifacts images=amet

    • A list of images to be pushed upon the successful completion of all build steps. The images will be pushed using the builder service account's credentials. The digests of the pushed images will be stored in the Build resource's results field. If any of the images fail to be pushed, the build is marked FAILURE.
    • Each invocation of this argument appends the given value to the array.
  • objects location=duo
    • Cloud Storage bucket and optional object path, in the form "gs://bucket/path/to/somewhere/". (see Bucket Name Requirements). Files in the workspace matching any path pattern will be uploaded to Cloud Storage with this location as a prefix.
  • paths=ipsum
    • Path globs used to match files in the build's workspace.
    • Each invocation of this argument appends the given value to the array.
  • timing end-time=sed
    • End of time span.
  • start-time=ut

    • Start of time span.
  • .... build-trigger-id=gubergren

    • Output only. The ID of the BuildTrigger that triggered this build, if it was triggered automatically.
  • create-time=rebum.
    • Output only. Time at which the request to create the build was received.
  • failure-info detail=est
    • Explains the failure issue in more detail using hard-coded text.
  • type=ipsum

    • The name of the failure.
  • .. finish-time=ipsum

    • Output only. Time at which execution of the build was finished. The difference between finish_time and start_time is the duration of the build's execution.
  • id=est
    • Output only. Unique identifier of the build.
  • images=gubergren
    • A list of images to be pushed upon the successful completion of all build steps. The images are pushed using the builder service account's credentials. The digests of the pushed images will be stored in the Build resource's results field. If any of the images fail to be pushed, the build status is marked FAILURE.
    • Each invocation of this argument appends the given value to the array.
  • log-url=ea
    • Output only. URL to logs for this build in Google Cloud Console.
  • logs-bucket=dolor
    • Cloud Storage bucket where logs should be written (see Bucket Name Requirements). Logs file names will be of the format ${logs_bucket}/log-${build_id}.txt.
  • name=lorem
    • Output only. The 'Build' name with format: projects/{project}/locations/{location}/builds/{build}, where {build} is a unique identifier generated by the service.
  • options automap-substitutions=false
    • Option to include built-in and custom substitutions as env variables for all build steps.
  • default-logs-bucket-behavior=sed
    • Optional. Option to specify how default logs buckets are setup.
  • disk-size-gb=duo
    • Requested disk size for the VM that runs the build. Note that this is NOT "disk free"; some of the space will be used by the operating system and build utilities. Also note that this is the minimum disk size that will be allocated for the build -- the build may run with a larger disk than requested. At present, the maximum disk size is 2000GB; builds that request more than the maximum are rejected with an error.
  • dynamic-substitutions=false
    • Option to specify whether or not to apply bash style string operations to the substitutions. NOTE: this is always enabled for triggered builds and cannot be overridden in the build configuration file.
  • env=no
    • A list of global environment variable definitions that will exist for all build steps in this build. If a variable is defined in both globally and in a build step, the variable will use the build step value. The elements are of the form "KEY=VALUE" for the environment variable "KEY" being given the value "VALUE".
    • Each invocation of this argument appends the given value to the array.
  • log-streaming-option=stet
    • Option to define build log streaming behavior to Cloud Storage.
  • logging=kasd
    • Option to specify the logging mode, which determines if and where build logs are stored.
  • machine-type=et
    • Compute Engine machine type on which to run the build.
  • pool name=sed

    • The WorkerPool resource to execute the build on. You must have cloudbuild.workerpools.use on the project hosting the WorkerPool. Format projects/{project}/locations/{location}/workerPools/{workerPoolId}
  • .. requested-verify-option=et

    • Requested verifiability options.
  • secret-env=et
    • A list of global environment variables, which are encrypted using a Cloud Key Management Service crypto key. These values must be specified in the build's Secret. These variables will be available to all build steps in this build.
    • Each invocation of this argument appends the given value to the array.
  • source-provenance-hash=vero
    • Requested hash for SourceProvenance.
    • Each invocation of this argument appends the given value to the array.
  • substitution-option=erat
    • Option to specify behavior when there is an error in the substitution checks. NOTE: this is always set to ALLOW_LOOSE for triggered builds and cannot be overridden in the build configuration file.
  • worker-pool=sed

    • This field deprecated; please use pool.name instead.
  • .. project-id=duo

    • Output only. ID of the project.
  • queue-ttl=dolore
    • TTL in queue for this build. If provided and the build is enqueued longer than this value, the build will expire and the build status will be EXPIRED. The TTL starts ticking from create_time.
  • results artifact-manifest=et
    • Path to the artifact manifest for non-container artifacts uploaded to Cloud Storage. Only populated when artifacts are uploaded to Cloud Storage.
  • artifact-timing end-time=voluptua.
    • End of time span.
  • start-time=amet.

    • Start of time span.
  • .. build-step-images=consetetur

    • List of build step digests, in the order corresponding to build step indices.
    • Each invocation of this argument appends the given value to the array.
  • build-step-outputs=diam
    • List of build step outputs, produced by builder images, in the order corresponding to build step indices. Cloud Builders can produce this output by writing to $BUILDER_OUTPUT/output. Only the first 50KB of data is stored.
    • Each invocation of this argument appends the given value to the array.
  • num-artifacts=dolor

    • Number of non-container artifacts uploaded to Cloud Storage. Only populated when artifacts are uploaded to Cloud Storage.
  • .. service-account=et

    • IAM service account whose credentials will be used at build runtime. Must be of the format projects/{PROJECT_ID}/serviceAccounts/{ACCOUNT}. ACCOUNT can be email address or uniqueId of the service account.
  • source.connected-repository dir=et
    • Directory, relative to the source root, in which to run the build.
  • repository=sadipscing
    • Required. Name of the Google Cloud Build repository, formatted as projects/*/locations/*/connections/*/repositories/*.
  • revision=stet

    • The revision to fetch from the Git repository such as a branch, a tag, a commit SHA, or any Git ref.
  • ..git-source dir=dolor

    • Directory, relative to the source root, in which to run the build. This must be a relative path. If a step's dir is specified and is an absolute path, this value is ignored for that step's execution.
  • revision=duo
    • The revision to fetch from the Git repository such as a branch, a tag, a commit SHA, or any Git ref. Cloud Build uses git fetch to fetch the revision from the Git repository; therefore make sure that the string you provide for revision is parsable by the command. For information on string values accepted by git fetch, see https://git-scm.com/docs/gitrevisions#_specifying_revisions. For information on git fetch, see https://git-scm.com/docs/git-fetch.
  • url=vero

    • Location of the Git repo to build. This will be used as a git remote, see https://git-scm.com/docs/git-remote.
  • ..repo-source branch-name=vero

    • Regex matching branches to build. The syntax of the regular expressions accepted is the syntax accepted by RE2 and described at https://github.com/google/re2/wiki/Syntax
  • commit-sha=invidunt
    • Explicit commit SHA to build.
  • dir=stet
    • Directory, relative to the source root, in which to run the build. This must be a relative path. If a step's dir is specified and is an absolute path, this value is ignored for that step's execution.
  • invert-regex=false
    • Only trigger a build if the revision regex does NOT match the revision regex.
  • project-id=elitr
    • ID of the project that owns the Cloud Source Repository. If omitted, the project ID requesting the build is assumed.
  • repo-name=lorem
    • Name of the Cloud Source Repository.
  • substitutions=key=diam
    • Substitutions to use in a triggered build. Should only be used with RunBuildTrigger
    • the value will be associated with the given key
  • tag-name=no

    • Regex matching tags to build. The syntax of the regular expressions accepted is the syntax accepted by RE2 and described at https://github.com/google/re2/wiki/Syntax
  • ..storage-source bucket=ipsum

  • generation=accusam
    • Cloud Storage generation for the object. If the generation is omitted, the latest generation will be used.
  • object=takimata
    • Cloud Storage object containing the source. This object must be a zipped (.zip) or gzipped archive file (.tar.gz) containing source to build.
  • source-fetcher=consetetur

    • Optional. Option to specify the tool to fetch the source file for the build.
  • ..storage-source-manifest bucket=voluptua.

  • generation=et
    • Cloud Storage generation for the object. If the generation is omitted, the latest generation will be used.
  • object=erat

    • Cloud Storage object containing the source manifest. This object must be a JSON file.
  • ...source-provenance.resolved-connected-repository dir=consetetur

    • Directory, relative to the source root, in which to run the build.
  • repository=amet.
    • Required. Name of the Google Cloud Build repository, formatted as projects/*/locations/*/connections/*/repositories/*.
  • revision=sed

    • The revision to fetch from the Git repository such as a branch, a tag, a commit SHA, or any Git ref.
  • ..resolved-git-source dir=takimata

    • Directory, relative to the source root, in which to run the build. This must be a relative path. If a step's dir is specified and is an absolute path, this value is ignored for that step's execution.
  • revision=dolores
    • The revision to fetch from the Git repository such as a branch, a tag, a commit SHA, or any Git ref. Cloud Build uses git fetch to fetch the revision from the Git repository; therefore make sure that the string you provide for revision is parsable by the command. For information on string values accepted by git fetch, see https://git-scm.com/docs/gitrevisions#_specifying_revisions. For information on git fetch, see https://git-scm.com/docs/git-fetch.
  • url=gubergren

    • Location of the Git repo to build. This will be used as a git remote, see https://git-scm.com/docs/git-remote.
  • ..resolved-repo-source branch-name=et

    • Regex matching branches to build. The syntax of the regular expressions accepted is the syntax accepted by RE2 and described at https://github.com/google/re2/wiki/Syntax
  • commit-sha=accusam
    • Explicit commit SHA to build.
  • dir=voluptua.
    • Directory, relative to the source root, in which to run the build. This must be a relative path. If a step's dir is specified and is an absolute path, this value is ignored for that step's execution.
  • invert-regex=false
    • Only trigger a build if the revision regex does NOT match the revision regex.
  • project-id=amet.
    • ID of the project that owns the Cloud Source Repository. If omitted, the project ID requesting the build is assumed.
  • repo-name=ea
    • Name of the Cloud Source Repository.
  • substitutions=key=sadipscing
    • Substitutions to use in a triggered build. Should only be used with RunBuildTrigger
    • the value will be associated with the given key
  • tag-name=lorem

    • Regex matching tags to build. The syntax of the regular expressions accepted is the syntax accepted by RE2 and described at https://github.com/google/re2/wiki/Syntax
  • ..resolved-storage-source bucket=invidunt

  • generation=no
    • Cloud Storage generation for the object. If the generation is omitted, the latest generation will be used.
  • object=est
    • Cloud Storage object containing the source. This object must be a zipped (.zip) or gzipped archive file (.tar.gz) containing source to build.
  • source-fetcher=at

    • Optional. Option to specify the tool to fetch the source file for the build.
  • ..resolved-storage-source-manifest bucket=sed

  • generation=sit
    • Cloud Storage generation for the object. If the generation is omitted, the latest generation will be used.
  • object=et

    • Cloud Storage object containing the source manifest. This object must be a JSON file.
  • ... start-time=tempor

    • Output only. Time at which execution of the build was started.
  • status=aliquyam
    • Output only. Status of the build.
  • status-detail=ipsum
    • Output only. Customer-readable message about the current status.
  • substitutions=key=et
    • Substitutions data for Build resource.
    • the value will be associated with the given key
  • tags=sanctus
    • Tags for annotation of a Build. These are not docker tags.
    • Each invocation of this argument appends the given value to the array.
  • timeout=lorem
    • Amount of time that this build should be allowed to run, to second granularity. If this amount of time elapses, work on the build will cease and the build status will be TIMEOUT. timeout starts ticking from startTime. Default time is 60 minutes.

About Cursors

The cursor position is key to comfortably set complex nested structures. The following rules apply:

  • The cursor position is always set relative to the current one, unless the field name starts with the . character. Fields can be nested such as in -r f.s.o .
  • The cursor position is set relative to the top-level structure if it starts with ., e.g. -r .s.s
  • You can also set nested fields without setting the cursor explicitly. For example, to set a value relative to the current cursor position, you would specify -r struct.sub_struct=bar.
  • You can move the cursor one level up by using ... Each additional . moves it up one additional level. E.g. ... would go three levels up.

Optional Output Flags

The method's return value a JSON encoded structure, which will be written to standard output by default.

  • -o out
    • out specifies the destination to which to write the server's result to. It will be a JSON-encoded structure. The destination may be - to indicate standard output, or a filepath that is to contain the received bytes. If unset, it defaults to standard output.

Optional Method Properties

You may set the following properties to further configure the call. Please note that -p is followed by one or more key-value-pairs, and is called like this -p k1=v1 k2=v2 even though the listing below repeats the -p for completeness.

  • -p parent=string
    • The parent resource where this build will be created. Format: projects/{project}/locations/{location}

Optional General Properties

The following properties can configure any call, and are not specific to this method.

  • -p $-xgafv=string

    • V1 error format.
  • -p access-token=string

    • OAuth access token.
  • -p alt=string

    • Data format for response.
  • -p callback=string

    • JSONP
  • -p fields=string

    • Selector specifying which fields to include in a partial response.
  • -p key=string

    • API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
  • -p oauth-token=string

    • OAuth 2.0 token for the current user.
  • -p pretty-print=boolean

    • Returns response with indentations and line breaks.
  • -p quota-user=string

    • Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
  • -p upload-type=string

    • Legacy upload protocol for media (e.g. "media", "multipart").
  • -p upload-protocol=string

    • Upload protocol for media (e.g. "raw", "multipart").