Class CloudBuildClient (2.0.2)
Stay organized with collections
Save and categorize content based on your preferences.
CloudBuildClient(*, credentials: google.auth.credentials.Credentials = None, transport: Union[str, google.cloud.devtools.cloudbuild_v1.services.cloud_build.transports.base.CloudBuildTransport] = None, client_options: <module 'google.api_core.client_options' from'/workspace/python-cloudbuild/.nox/docfx/lib/python3.9/site-packages/google/api_core/client_options.py'> = None)Creates and manages builds on Google Cloud Platform.
The main concept used by this API is a Build, which describes
the location of the source to build, how to build the source, and
where to store the built artifacts, if any.
A user can list previously-requested builds or get builds by their ID to determine the status of the build.
Methods
CloudBuildClient
CloudBuildClient(*, credentials: google.auth.credentials.Credentials = None, transport: Union[str, google.cloud.devtools.cloudbuild_v1.services.cloud_build.transports.base.CloudBuildTransport] = None, client_options: <module 'google.api_core.client_options' from'/workspace/python-cloudbuild/.nox/docfx/lib/python3.9/site-packages/google/api_core/client_options.py'> = None)Instantiate the cloud build client.
credentials
Optional[google.auth.credentials.Credentials]
The authorization credentials to attach to requests. These credentials identify the application to the service; if none are specified, the client will attempt to ascertain the credentials from the environment.
transport
Union[str, .CloudBuildTransport]
The transport to use. If set to None, a transport is chosen automatically.
client_options
ClientOptions
Custom options for the client. It won't take effect if a transport instance is provided. (1) The api_endpoint property can be used to override the default endpoint provided by the client. GOOGLE_API_USE_MTLS environment variable can also be used to override the endpoint: "always" (always use the default mTLS endpoint), "never" (always use the default regular endpoint, this is the default value for the environment variable) and "auto" (auto switch to the default mTLS endpoint if client SSL credentials is present). However, the api_endpoint property takes precedence if provided. (2) The client_cert_source property is used to provide client SSL credentials for mutual TLS transport. If not provided, the default SSL credentials will be used if present.
google.auth.exceptions.MutualTLSChannelError
If mutual TLS transport creation failed for any reason.
cancel_build
cancel_build(request: Optional[google.cloud.devtools.cloudbuild_v1.types.cloudbuild.CancelBuildRequest] = None, *, project_id: Optional[str] = None, id: Optional[str] = None, retry: google.api_core.retry.Retry = <_MethodDefault._DEFAULT_VALUE: <object object>>, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = ())Cancels a build in progress.
request
.cloudbuild.CancelBuildRequest
The request object. Request to cancel an ongoing build.
project_id
str
Required. ID of the project. This corresponds to the project_id field on the request instance; if request is provided, this should not be set.
id
str
Required. ID of the build. This corresponds to the id field on the request instance; if request is provided, this should not be set.
retry
google.api_core.retry.Retry
Designation of what errors, if any, should be retried.
timeout
float
The timeout for this request.
metadata
Sequence[Tuple[str, str]]
Strings which should be sent along with the request as metadata.
.cloudbuild.Build
A build resource in the Cloud Build API. At a high level, a Build describes where to find source code, how to build it (for example, the builder image to run on the source), and where to store the built artifacts. Fields can include the following variables, which will be expanded when the build is created: - $PROJECT_ID: the project ID of the build. - $BUILD_ID: the autogenerated ID of the build. - $REPO_NAME: the source repository name specified by RepoSource. - $BRANCH_NAME: the branch name specified by RepoSource. - $TAG_NAME: the tag name specified by RepoSource. - $REVISION_ID or $COMMIT_SHA: the commit SHA specified by RepoSource or resolved from the specified branch or tag. - $SHORT_SHA: first 7 characters of $REVISION_ID or $COMMIT_SHA.
create_build
create_build(request: Optional[google.cloud.devtools.cloudbuild_v1.types.cloudbuild.CreateBuildRequest] = None, *, project_id: Optional[str] = None, build: Optional[google.cloud.devtools.cloudbuild_v1.types.cloudbuild.Build] = None, retry: google.api_core.retry.Retry = <_MethodDefault._DEFAULT_VALUE: <object object>>, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = ())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).
request
.cloudbuild.CreateBuildRequest
The request object. Request to create a new build.
project_id
str
Required. ID of the project. This corresponds to the project_id field on the request instance; if request is provided, this should not be set.
build
.cloudbuild.Build
Required. Build resource to create. This corresponds to the build field on the request instance; if request is provided, this should not be set.
retry
google.api_core.retry.Retry
Designation of what errors, if any, should be retried.
timeout
float
The timeout for this request.
metadata
Sequence[Tuple[str, str]]
Strings which should be sent along with the request as metadata.
.operation.Operation
An object representing a long-running operation. The result type for the operation will be .cloudbuild.Build
Build describes where to find source code, how to build it (for example, the builder image to run on the source), and where to store the built artifacts. Fields can include the following variables, which will be expanded when the build is created: - $PROJECT_ID: the project ID of the build. - $BUILD_ID: the autogenerated ID of the build. - $REPO_NAME: the source repository name specified by RepoSource. - $BRANCH_NAME: the branch name specified by RepoSource. - $TAG_NAME: the tag name specified by RepoSource. - $REVISION_ID or $COMMIT_SHA: the commit SHA specified by RepoSource or resolved from the specified branch or tag. - $SHORT_SHA: first 7 characters of $REVISION_ID or $COMMIT_SHA.
create_build_trigger
create_build_trigger(request: Optional[google.cloud.devtools.cloudbuild_v1.types.cloudbuild.CreateBuildTriggerRequest] = None, *, project_id: Optional[str] = None, trigger: Optional[google.cloud.devtools.cloudbuild_v1.types.cloudbuild.BuildTrigger] = None, retry: google.api_core.retry.Retry = <_MethodDefault._DEFAULT_VALUE: <object object>>, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = ())Creates a new BuildTrigger.
This API is experimental.
request
.cloudbuild.CreateBuildTriggerRequest
The request object. Request to create a new BuildTrigger.
project_id
str
Required. ID of the project for which to configure automatic builds. This corresponds to the project_id field on the request instance; if request is provided, this should not be set.
trigger
.cloudbuild.BuildTrigger
Required. BuildTrigger to create. This corresponds to the trigger field on the request instance; if request is provided, this should not be set.
retry
google.api_core.retry.Retry
Designation of what errors, if any, should be retried.
timeout
float
The timeout for this request.
metadata
Sequence[Tuple[str, str]]
Strings which should be sent along with the request as metadata.
.cloudbuild.BuildTrigger
Configuration for an automated build in response to source repository changes.
create_worker_pool
create_worker_pool(request: Optional[google.cloud.devtools.cloudbuild_v1.types.cloudbuild.CreateWorkerPoolRequest] = None, *, retry: google.api_core.retry.Retry = <_MethodDefault._DEFAULT_VALUE: <object object>>, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = ())Creates a WorkerPool to run the builds, and returns the new
worker pool.
This API is experimental.
request
.cloudbuild.CreateWorkerPoolRequest
The request object. Request to create a new WorkerPool.
retry
google.api_core.retry.Retry
Designation of what errors, if any, should be retried.
timeout
float
The timeout for this request.
metadata
Sequence[Tuple[str, str]]
Strings which should be sent along with the request as metadata.
.cloudbuild.WorkerPool
Configuration for a WorkerPool to run the builds. Workers are machines that Cloud Build uses to run your builds. By default, all workers run in a project owned by Cloud Build. To have full control over the workers that execute your builds -- such as enabling them to access private resources on your private network -- you can request Cloud Build to run the workers in your own project by creating a custom workers pool.
delete_build_trigger
delete_build_trigger(request: Optional[google.cloud.devtools.cloudbuild_v1.types.cloudbuild.DeleteBuildTriggerRequest] = None, *, project_id: Optional[str] = None, trigger_id: Optional[str] = None, retry: google.api_core.retry.Retry = <_MethodDefault._DEFAULT_VALUE: <object object>>, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = ())Deletes a BuildTrigger by its project ID and trigger ID.
This API is experimental.
request
.cloudbuild.DeleteBuildTriggerRequest
The request object. Request to delete a BuildTrigger.
project_id
str
Required. ID of the project that owns the trigger. This corresponds to the project_id field on the request instance; if request is provided, this should not be set.
trigger_id
str
Required. ID of the BuildTrigger to delete. This corresponds to the trigger_id field on the request instance; if request is provided, this should not be set.
retry
google.api_core.retry.Retry
Designation of what errors, if any, should be retried.
timeout
float
The timeout for this request.
metadata
Sequence[Tuple[str, str]]
Strings which should be sent along with the request as metadata.
delete_worker_pool
delete_worker_pool(request: Optional[google.cloud.devtools.cloudbuild_v1.types.cloudbuild.DeleteWorkerPoolRequest] = None, *, retry: google.api_core.retry.Retry = <_MethodDefault._DEFAULT_VALUE: <object object>>, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = ())Deletes a WorkerPool by its project ID and WorkerPool name.
This API is experimental.
request
.cloudbuild.DeleteWorkerPoolRequest
The request object. Request to delete a WorkerPool.
retry
google.api_core.retry.Retry
Designation of what errors, if any, should be retried.
timeout
float
The timeout for this request.
metadata
Sequence[Tuple[str, str]]
Strings which should be sent along with the request as metadata.
from_service_account_file
from_service_account_file(filename: str, *args, **kwargs)Creates an instance of this client using the provided credentials file.
filename
str
The path to the service account private key json file.
{@api.name}
The constructed client.
from_service_account_json
from_service_account_json(filename: str, *args, **kwargs)Creates an instance of this client using the provided credentials file.
filename
str
The path to the service account private key json file.
{@api.name}
The constructed client.
get_build
get_build(request: Optional[google.cloud.devtools.cloudbuild_v1.types.cloudbuild.GetBuildRequest] = None, *, project_id: Optional[str] = None, id: Optional[str] = None, retry: google.api_core.retry.Retry = <_MethodDefault._DEFAULT_VALUE: <object object>>, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = ())Returns information about a previously requested build.
The Build that is returned includes its status (such as
SUCCESS, FAILURE, or WORKING), and timing
information.
request
.cloudbuild.GetBuildRequest
The request object. Request to get a build.
project_id
str
Required. ID of the project. This corresponds to the project_id field on the request instance; if request is provided, this should not be set.
id
str
Required. ID of the build. This corresponds to the id field on the request instance; if request is provided, this should not be set.
retry
google.api_core.retry.Retry
Designation of what errors, if any, should be retried.
timeout
float
The timeout for this request.
metadata
Sequence[Tuple[str, str]]
Strings which should be sent along with the request as metadata.
.cloudbuild.Build
A build resource in the Cloud Build API. At a high level, a Build describes where to find source code, how to build it (for example, the builder image to run on the source), and where to store the built artifacts. Fields can include the following variables, which will be expanded when the build is created: - $PROJECT_ID: the project ID of the build. - $BUILD_ID: the autogenerated ID of the build. - $REPO_NAME: the source repository name specified by RepoSource. - $BRANCH_NAME: the branch name specified by RepoSource. - $TAG_NAME: the tag name specified by RepoSource. - $REVISION_ID or $COMMIT_SHA: the commit SHA specified by RepoSource or resolved from the specified branch or tag. - $SHORT_SHA: first 7 characters of $REVISION_ID or $COMMIT_SHA.
get_build_trigger
get_build_trigger(request: Optional[google.cloud.devtools.cloudbuild_v1.types.cloudbuild.GetBuildTriggerRequest] = None, *, project_id: Optional[str] = None, trigger_id: Optional[str] = None, retry: google.api_core.retry.Retry = <_MethodDefault._DEFAULT_VALUE: <object object>>, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = ())Returns information about a BuildTrigger.
This API is experimental.
request
.cloudbuild.GetBuildTriggerRequest
The request object. Returns the BuildTrigger with the specified ID.
project_id
str
Required. ID of the project that owns the trigger. This corresponds to the project_id field on the request instance; if request is provided, this should not be set.
trigger_id
str
Required. Identifier (id or name) of the BuildTrigger to get. This corresponds to the trigger_id field on the request instance; if request is provided, this should not be set.
retry
google.api_core.retry.Retry
Designation of what errors, if any, should be retried.
timeout
float
The timeout for this request.
metadata
Sequence[Tuple[str, str]]
Strings which should be sent along with the request as metadata.
.cloudbuild.BuildTrigger
Configuration for an automated build in response to source repository changes.
get_worker_pool
get_worker_pool(request: Optional[google.cloud.devtools.cloudbuild_v1.types.cloudbuild.GetWorkerPoolRequest] = None, *, retry: google.api_core.retry.Retry = <_MethodDefault._DEFAULT_VALUE: <object object>>, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = ())Returns information about a WorkerPool.
This API is experimental.
request
.cloudbuild.GetWorkerPoolRequest
The request object. Request to get a WorkerPool with the specified name.
retry
google.api_core.retry.Retry
Designation of what errors, if any, should be retried.
timeout
float
The timeout for this request.
metadata
Sequence[Tuple[str, str]]
Strings which should be sent along with the request as metadata.
.cloudbuild.WorkerPool
Configuration for a WorkerPool to run the builds. Workers are machines that Cloud Build uses to run your builds. By default, all workers run in a project owned by Cloud Build. To have full control over the workers that execute your builds -- such as enabling them to access private resources on your private network -- you can request Cloud Build to run the workers in your own project by creating a custom workers pool.
list_build_triggers
list_build_triggers(request: Optional[google.cloud.devtools.cloudbuild_v1.types.cloudbuild.ListBuildTriggersRequest] = None, *, project_id: Optional[str] = None, retry: google.api_core.retry.Retry = <_MethodDefault._DEFAULT_VALUE: <object object>>, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = ())Lists existing BuildTrigger\ s.
This API is experimental.
request
.cloudbuild.ListBuildTriggersRequest
The request object. Request to list existing BuildTriggers.
project_id
str
Required. ID of the project for which to list BuildTriggers. This corresponds to the project_id field on the request instance; if request is provided, this should not be set.
retry
google.api_core.retry.Retry
Designation of what errors, if any, should be retried.
timeout
float
The timeout for this request.
metadata
Sequence[Tuple[str, str]]
Strings which should be sent along with the request as metadata.
.pagers.ListBuildTriggersPager
Response containing existing BuildTriggers. Iterating over this object will yield results and resolve additional pages automatically.
list_builds
list_builds(request: Optional[google.cloud.devtools.cloudbuild_v1.types.cloudbuild.ListBuildsRequest] = None, *, project_id: Optional[str] = None, filter: Optional[str] = None, retry: google.api_core.retry.Retry = <_MethodDefault._DEFAULT_VALUE: <object object>>, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = ())Lists previously requested builds. Previously requested builds may still be in-progress, or may have finished successfully or unsuccessfully.
request
.cloudbuild.ListBuildsRequest
The request object. Request to list builds.
project_id
str
Required. ID of the project. This corresponds to the project_id field on the request instance; if request is provided, this should not be set.
filter
str
The raw filter text to constrain the results. This corresponds to the filter field on the request instance; if request is provided, this should not be set.
retry
google.api_core.retry.Retry
Designation of what errors, if any, should be retried.
timeout
float
The timeout for this request.
metadata
Sequence[Tuple[str, str]]
Strings which should be sent along with the request as metadata.
.pagers.ListBuildsPager
Response including listed builds. Iterating over this object will yield results and resolve additional pages automatically.
list_worker_pools
list_worker_pools(request: Optional[google.cloud.devtools.cloudbuild_v1.types.cloudbuild.ListWorkerPoolsRequest] = None, *, retry: google.api_core.retry.Retry = <_MethodDefault._DEFAULT_VALUE: <object object>>, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = ())List project's WorkerPools.
This API is experimental.
request
.cloudbuild.ListWorkerPoolsRequest
The request object. Request to list WorkerPools.
retry
google.api_core.retry.Retry
Designation of what errors, if any, should be retried.
timeout
float
The timeout for this request.
metadata
Sequence[Tuple[str, str]]
Strings which should be sent along with the request as metadata.
.cloudbuild.ListWorkerPoolsResponse
Response containing existing WorkerPools.
retry_build
retry_build(request: Optional[google.cloud.devtools.cloudbuild_v1.types.cloudbuild.RetryBuildRequest] = None, *, project_id: Optional[str] = None, id: Optional[str] = None, retry: google.api_core.retry.Retry = <_MethodDefault._DEFAULT_VALUE: <object object>>, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = ())Creates a new build based on the specified build.
This method creates a new build using the original build request, which may or may not result in an identical build.
For triggered builds:
- Triggered builds resolve to a precise revision; therefore a retry of a triggered build will result in a build that uses the same revision.
For non-triggered builds that specify RepoSource:
- If the original build built from the tip of a branch, the retried build will build from the tip of that branch, which may not be the same revision as the original build.
- If the original build specified a commit sha or revision ID, the retried build will use the identical source.
For builds that specify StorageSource:
- If the original build pulled source from Google Cloud Storage without specifying the generation of the object, the new build will use the current object, which may be different from the original build source.
- If the original build pulled source from Cloud Storage and specified the generation of the object, the new build will attempt to use the same object, which may or may not be available depending on the bucket's lifecycle management settings.
request
.cloudbuild.RetryBuildRequest
The request object. Specifies a build to retry.
project_id
str
Required. ID of the project. This corresponds to the project_id field on the request instance; if request is provided, this should not be set.
id
str
Required. Build ID of the original build. This corresponds to the id field on the request instance; if request is provided, this should not be set.
retry
google.api_core.retry.Retry
Designation of what errors, if any, should be retried.
timeout
float
The timeout for this request.
metadata
Sequence[Tuple[str, str]]
Strings which should be sent along with the request as metadata.
.operation.Operation
An object representing a long-running operation. The result type for the operation will be .cloudbuild.Build
Build describes where to find source code, how to build it (for example, the builder image to run on the source), and where to store the built artifacts. Fields can include the following variables, which will be expanded when the build is created: - $PROJECT_ID: the project ID of the build. - $BUILD_ID: the autogenerated ID of the build. - $REPO_NAME: the source repository name specified by RepoSource. - $BRANCH_NAME: the branch name specified by RepoSource. - $TAG_NAME: the tag name specified by RepoSource. - $REVISION_ID or $COMMIT_SHA: the commit SHA specified by RepoSource or resolved from the specified branch or tag. - $SHORT_SHA: first 7 characters of $REVISION_ID or $COMMIT_SHA.
run_build_trigger
run_build_trigger(request: Optional[google.cloud.devtools.cloudbuild_v1.types.cloudbuild.RunBuildTriggerRequest] = None, *, project_id: Optional[str] = None, trigger_id: Optional[str] = None, source: Optional[google.cloud.devtools.cloudbuild_v1.types.cloudbuild.RepoSource] = None, retry: google.api_core.retry.Retry = <_MethodDefault._DEFAULT_VALUE: <object object>>, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = ())Runs a BuildTrigger at a particular source revision.
request
.cloudbuild.RunBuildTriggerRequest
The request object. Specifies a build trigger to run and the source to use.
project_id
str
Required. ID of the project. This corresponds to the project_id field on the request instance; if request is provided, this should not be set.
trigger_id
str
Required. ID of the trigger. This corresponds to the trigger_id field on the request instance; if request is provided, this should not be set.
source
.cloudbuild.RepoSource
Required. Source to build against this trigger. This corresponds to the source field on the request instance; if request is provided, this should not be set.
retry
google.api_core.retry.Retry
Designation of what errors, if any, should be retried.
timeout
float
The timeout for this request.
metadata
Sequence[Tuple[str, str]]
Strings which should be sent along with the request as metadata.
.operation.Operation
An object representing a long-running operation. The result type for the operation will be .cloudbuild.Build
Build describes where to find source code, how to build it (for example, the builder image to run on the source), and where to store the built artifacts. Fields can include the following variables, which will be expanded when the build is created: - $PROJECT_ID: the project ID of the build. - $BUILD_ID: the autogenerated ID of the build. - $REPO_NAME: the source repository name specified by RepoSource. - $BRANCH_NAME: the branch name specified by RepoSource. - $TAG_NAME: the tag name specified by RepoSource. - $REVISION_ID or $COMMIT_SHA: the commit SHA specified by RepoSource or resolved from the specified branch or tag. - $SHORT_SHA: first 7 characters of $REVISION_ID or $COMMIT_SHA.
update_build_trigger
update_build_trigger(request: Optional[google.cloud.devtools.cloudbuild_v1.types.cloudbuild.UpdateBuildTriggerRequest] = None, *, project_id: Optional[str] = None, trigger_id: Optional[str] = None, trigger: Optional[google.cloud.devtools.cloudbuild_v1.types.cloudbuild.BuildTrigger] = None, retry: google.api_core.retry.Retry = <_MethodDefault._DEFAULT_VALUE: <object object>>, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = ())Updates a BuildTrigger by its project ID and trigger ID.
This API is experimental.
request
.cloudbuild.UpdateBuildTriggerRequest
The request object. Request to update an existing BuildTrigger.
project_id
str
Required. ID of the project that owns the trigger. This corresponds to the project_id field on the request instance; if request is provided, this should not be set.
trigger_id
str
Required. ID of the BuildTrigger to update. This corresponds to the trigger_id field on the request instance; if request is provided, this should not be set.
trigger
.cloudbuild.BuildTrigger
Required. BuildTrigger to update. This corresponds to the trigger field on the request instance; if request is provided, this should not be set.
retry
google.api_core.retry.Retry
Designation of what errors, if any, should be retried.
timeout
float
The timeout for this request.
metadata
Sequence[Tuple[str, str]]
Strings which should be sent along with the request as metadata.
.cloudbuild.BuildTrigger
Configuration for an automated build in response to source repository changes.
update_worker_pool
update_worker_pool(request: Optional[google.cloud.devtools.cloudbuild_v1.types.cloudbuild.UpdateWorkerPoolRequest] = None, *, retry: google.api_core.retry.Retry = <_MethodDefault._DEFAULT_VALUE: <object object>>, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = ())Update a WorkerPool.
This API is experimental.
request
.cloudbuild.UpdateWorkerPoolRequest
The request object. Request to update a WorkerPool.
retry
google.api_core.retry.Retry
Designation of what errors, if any, should be retried.
timeout
float
The timeout for this request.
metadata
Sequence[Tuple[str, str]]
Strings which should be sent along with the request as metadata.
.cloudbuild.WorkerPool
Configuration for a WorkerPool to run the builds. Workers are machines that Cloud Build uses to run your builds. By default, all workers run in a project owned by Cloud Build. To have full control over the workers that execute your builds -- such as enabling them to access private resources on your private network -- you can request Cloud Build to run the workers in your own project by creating a custom workers pool.