CloudBuildClient(
transport=None,
channel=None,
credentials=None,
client_config=None,
client_info=None,
client_options=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(
transport=None,
channel=None,
credentials=None,
client_config=None,
client_info=None,
client_options=None,
)
Constructor.
Name | Description |
channel |
grpc.Channel
DEPRECATED. A |
credentials |
google.auth.credentials.Credentials
The authorization credentials to attach to requests. These credentials identify this application to the service. If none are specified, the client will attempt to ascertain the credentials from the environment. This argument is mutually exclusive with providing a transport instance to |
client_config |
dict
DEPRECATED. A dictionary of call options for each method. If not specified, the default configuration is used. |
client_info |
google.api_core.gapic_v1.client_info.ClientInfo
The client info used to send a user-agent string along with API requests. If |
client_options |
Union[dict, google.api_core.client_options.ClientOptions]
Client options used to set user options on the client. API Endpoint should be set through client_options. |
cancel_build
cancel_build(project_id, id_, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)
Cancels a build in progress.
.. rubric:: Example
from google.cloud.devtools import cloudbuild_v1
client = cloudbuild_v1.CloudBuildClient()
TODO: Initialize
project_id
:project_id = ''
TODO: Initialize
id_
:id_ = ''
response = client.cancel_build(project_id, id_)
Name | Description |
project_id |
str
Required. ID of the project. |
id_ |
str
Required. ID of the build. |
retry |
Optional[google.api_core.retry.Retry]
A retry object used to retry requests. If |
timeout |
Optional[float]
The amount of time, in seconds, to wait for the request to complete. Note that if |
metadata |
Optional[Sequence[Tuple[str, str]]]
Additional metadata that is provided to the method. |
Type | Description |
google.api_core.exceptions.GoogleAPICallError | If the request failed for any reason. |
google.api_core.exceptions.RetryError | If the request failed due to a retryable error and retry attempts failed. |
ValueError | If the parameters are invalid. |
create_build
create_build(project_id, build, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)
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
).
.. rubric:: Example
from google.cloud.devtools import cloudbuild_v1
client = cloudbuild_v1.CloudBuildClient()
TODO: Initialize
project_id
:project_id = ''
TODO: Initialize
build
:build = {}
response = client.create_build(project_id, build)
def callback(operation_future): ... # Handle result. ... result = operation_future.result()
response.add_done_callback(callback)
Handle metadata.
metadata = response.metadata()
Name | Description |
project_id |
str
Required. ID of the project. |
build |
Union[dict, Build]
Required. Build resource to create. If a dict is provided, it must be of the same form as the protobuf message Build |
retry |
Optional[google.api_core.retry.Retry]
A retry object used to retry requests. If |
timeout |
Optional[float]
The amount of time, in seconds, to wait for the request to complete. Note that if |
metadata |
Optional[Sequence[Tuple[str, str]]]
Additional metadata that is provided to the method. |
Type | Description |
google.api_core.exceptions.GoogleAPICallError | If the request failed for any reason. |
google.api_core.exceptions.RetryError | If the request failed due to a retryable error and retry attempts failed. |
ValueError | If the parameters are invalid. |
create_build_trigger
create_build_trigger(project_id, trigger, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)
Creates a new BuildTrigger
.
This API is experimental.
.. rubric:: Example
from google.cloud.devtools import cloudbuild_v1
client = cloudbuild_v1.CloudBuildClient()
TODO: Initialize
project_id
:project_id = ''
TODO: Initialize
trigger
:trigger = {}
response = client.create_build_trigger(project_id, trigger)
Name | Description |
project_id |
str
Required. ID of the project for which to configure automatic builds. |
trigger |
Union[dict, BuildTrigger]
Required. |
retry |
Optional[google.api_core.retry.Retry]
A retry object used to retry requests. If |
timeout |
Optional[float]
The amount of time, in seconds, to wait for the request to complete. Note that if |
metadata |
Optional[Sequence[Tuple[str, str]]]
Additional metadata that is provided to the method. |
Type | Description |
google.api_core.exceptions.GoogleAPICallError | If the request failed for any reason. |
google.api_core.exceptions.RetryError | If the request failed due to a retryable error and retry attempts failed. |
ValueError | If the parameters are invalid. |
create_worker_pool
create_worker_pool(parent=None, worker_pool=None, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)
Creates a WorkerPool
to run the builds, and returns the new
worker pool.
This API is experimental.
.. rubric:: Example
from google.cloud.devtools import cloudbuild_v1
client = cloudbuild_v1.CloudBuildClient()
response = client.create_worker_pool()
Name | Description |
parent |
str
ID of the parent project. |
worker_pool |
Union[dict, WorkerPool]
|
retry |
Optional[google.api_core.retry.Retry]
A retry object used to retry requests. If |
timeout |
Optional[float]
The amount of time, in seconds, to wait for the request to complete. Note that if |
metadata |
Optional[Sequence[Tuple[str, str]]]
Additional metadata that is provided to the method. |
Type | Description |
google.api_core.exceptions.GoogleAPICallError | If the request failed for any reason. |
google.api_core.exceptions.RetryError | If the request failed due to a retryable error and retry attempts failed. |
ValueError | If the parameters are invalid. |
delete_build_trigger
delete_build_trigger(project_id, trigger_id, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)
Deletes a BuildTrigger
by its project ID and trigger ID.
This API is experimental.
.. rubric:: Example
from google.cloud.devtools import cloudbuild_v1
client = cloudbuild_v1.CloudBuildClient()
TODO: Initialize
project_id
:project_id = ''
TODO: Initialize
trigger_id
:trigger_id = ''
client.delete_build_trigger(project_id, trigger_id)
Name | Description |
project_id |
str
Required. ID of the project that owns the trigger. |
trigger_id |
str
Required. ID of the |
retry |
Optional[google.api_core.retry.Retry]
A retry object used to retry requests. If |
timeout |
Optional[float]
The amount of time, in seconds, to wait for the request to complete. Note that if |
metadata |
Optional[Sequence[Tuple[str, str]]]
Additional metadata that is provided to the method. |
Type | Description |
google.api_core.exceptions.GoogleAPICallError | If the request failed for any reason. |
google.api_core.exceptions.RetryError | If the request failed due to a retryable error and retry attempts failed. |
ValueError | If the parameters are invalid. |
delete_worker_pool
delete_worker_pool(name=None, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)
Deletes a WorkerPool
by its project ID and WorkerPool name.
This API is experimental.
.. rubric:: Example
from google.cloud.devtools import cloudbuild_v1
client = cloudbuild_v1.CloudBuildClient()
client.delete_worker_pool()
Name | Description |
name |
str
The field will contain name of the resource requested, for example: "projects/project-1/workerPools/workerpool-name" |
retry |
Optional[google.api_core.retry.Retry]
A retry object used to retry requests. If |
timeout |
Optional[float]
The amount of time, in seconds, to wait for the request to complete. Note that if |
metadata |
Optional[Sequence[Tuple[str, str]]]
Additional metadata that is provided to the method. |
Type | Description |
google.api_core.exceptions.GoogleAPICallError | If the request failed for any reason. |
google.api_core.exceptions.RetryError | If the request failed due to a retryable error and retry attempts failed. |
ValueError | If the parameters are invalid. |
from_service_account_file
from_service_account_file(filename, *args, **kwargs)
Creates an instance of this client using the provided credentials file.
Name | Description |
filename |
str
The path to the service account private key json file. |
Type | Description |
CloudBuildClient | The constructed client. |
from_service_account_json
from_service_account_json(filename, *args, **kwargs)
Creates an instance of this client using the provided credentials file.
Name | Description |
filename |
str
The path to the service account private key json file. |
Type | Description |
CloudBuildClient | The constructed client. |
get_build
get_build(project_id, id_, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)
Returns information about a previously requested build.
The Build
that is returned includes its status (such as SUCCESS
,
FAILURE
, or WORKING
), and timing information.
.. rubric:: Example
from google.cloud.devtools import cloudbuild_v1
client = cloudbuild_v1.CloudBuildClient()
TODO: Initialize
project_id
:project_id = ''
TODO: Initialize
id_
:id_ = ''
response = client.get_build(project_id, id_)
Name | Description |
project_id |
str
Required. ID of the project. |
id_ |
str
Required. ID of the build. |
retry |
Optional[google.api_core.retry.Retry]
A retry object used to retry requests. If |
timeout |
Optional[float]
The amount of time, in seconds, to wait for the request to complete. Note that if |
metadata |
Optional[Sequence[Tuple[str, str]]]
Additional metadata that is provided to the method. |
Type | Description |
google.api_core.exceptions.GoogleAPICallError | If the request failed for any reason. |
google.api_core.exceptions.RetryError | If the request failed due to a retryable error and retry attempts failed. |
ValueError | If the parameters are invalid. |
get_build_trigger
get_build_trigger(project_id, trigger_id, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)
Returns information about a BuildTrigger
.
This API is experimental.
.. rubric:: Example
from google.cloud.devtools import cloudbuild_v1
client = cloudbuild_v1.CloudBuildClient()
TODO: Initialize
project_id
:project_id = ''
TODO: Initialize
trigger_id
:trigger_id = ''
response = client.get_build_trigger(project_id, trigger_id)
Name | Description |
project_id |
str
Required. ID of the project that owns the trigger. |
trigger_id |
str
Required. Identifier ( |
retry |
Optional[google.api_core.retry.Retry]
A retry object used to retry requests. If |
timeout |
Optional[float]
The amount of time, in seconds, to wait for the request to complete. Note that if |
metadata |
Optional[Sequence[Tuple[str, str]]]
Additional metadata that is provided to the method. |
Type | Description |
google.api_core.exceptions.GoogleAPICallError | If the request failed for any reason. |
google.api_core.exceptions.RetryError | If the request failed due to a retryable error and retry attempts failed. |
ValueError | If the parameters are invalid. |
get_worker_pool
get_worker_pool(name=None, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)
Returns information about a WorkerPool
.
This API is experimental.
.. rubric:: Example
from google.cloud.devtools import cloudbuild_v1
client = cloudbuild_v1.CloudBuildClient()
response = client.get_worker_pool()
Name | Description |
name |
str
The field will contain name of the resource requested, for example: "projects/project-1/workerPools/workerpool-name" |
retry |
Optional[google.api_core.retry.Retry]
A retry object used to retry requests. If |
timeout |
Optional[float]
The amount of time, in seconds, to wait for the request to complete. Note that if |
metadata |
Optional[Sequence[Tuple[str, str]]]
Additional metadata that is provided to the method. |
Type | Description |
google.api_core.exceptions.GoogleAPICallError | If the request failed for any reason. |
google.api_core.exceptions.RetryError | If the request failed due to a retryable error and retry attempts failed. |
ValueError | If the parameters are invalid. |
list_build_triggers
list_build_triggers(project_id, page_size=None, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)
Lists existing BuildTrigger
\ s.
This API is experimental.
.. rubric:: Example
from google.cloud.devtools import cloudbuild_v1
client = cloudbuild_v1.CloudBuildClient()
TODO: Initialize
project_id
:project_id = ''
Iterate over all results
for element in client.list_build_triggers(project_id): ... # process element ... pass
Alternatively:
Iterate over results one page at a time
for page in client.list_build_triggers(project_id).pages: ... for element in page: ... # process element ... pass
Name | Description |
project_id |
str
Required. ID of the project for which to list BuildTriggers. |
page_size |
int
The maximum number of resources contained in the underlying API response. If page streaming is performed per- resource, this parameter does not affect the return value. If page streaming is performed per-page, this determines the maximum number of resources in a page. |
retry |
Optional[google.api_core.retry.Retry]
A retry object used to retry requests. If |
timeout |
Optional[float]
The amount of time, in seconds, to wait for the request to complete. Note that if |
metadata |
Optional[Sequence[Tuple[str, str]]]
Additional metadata that is provided to the method. |
Type | Description |
google.api_core.exceptions.GoogleAPICallError | If the request failed for any reason. |
google.api_core.exceptions.RetryError | If the request failed due to a retryable error and retry attempts failed. |
ValueError | If the parameters are invalid. |
list_builds
list_builds(project_id, page_size=None, filter_=None, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)
Lists previously requested builds.
Previously requested builds may still be in-progress, or may have finished successfully or unsuccessfully.
.. rubric:: Example
from google.cloud.devtools import cloudbuild_v1
client = cloudbuild_v1.CloudBuildClient()
TODO: Initialize
project_id
:project_id = ''
Iterate over all results
for element in client.list_builds(project_id): ... # process element ... pass
Alternatively:
Iterate over results one page at a time
for page in client.list_builds(project_id).pages: ... for element in page: ... # process element ... pass
Name | Description |
project_id |
str
Required. ID of the project. |
page_size |
int
The maximum number of resources contained in the underlying API response. If page streaming is performed per- resource, this parameter does not affect the return value. If page streaming is performed per-page, this determines the maximum number of resources in a page. |
filter_ |
str
The raw filter text to constrain the results. |
retry |
Optional[google.api_core.retry.Retry]
A retry object used to retry requests. If |
timeout |
Optional[float]
The amount of time, in seconds, to wait for the request to complete. Note that if |
metadata |
Optional[Sequence[Tuple[str, str]]]
Additional metadata that is provided to the method. |
Type | Description |
google.api_core.exceptions.GoogleAPICallError | If the request failed for any reason. |
google.api_core.exceptions.RetryError | If the request failed due to a retryable error and retry attempts failed. |
ValueError | If the parameters are invalid. |
list_worker_pools
list_worker_pools(parent=None, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)
List project's WorkerPool
\ s.
This API is experimental.
.. rubric:: Example
from google.cloud.devtools import cloudbuild_v1
client = cloudbuild_v1.CloudBuildClient()
response = client.list_worker_pools()
Name | Description |
parent |
str
ID of the parent project. |
retry |
Optional[google.api_core.retry.Retry]
A retry object used to retry requests. If |
timeout |
Optional[float]
The amount of time, in seconds, to wait for the request to complete. Note that if |
metadata |
Optional[Sequence[Tuple[str, str]]]
Additional metadata that is provided to the method. |
Type | Description |
google.api_core.exceptions.GoogleAPICallError | If the request failed for any reason. |
google.api_core.exceptions.RetryError | If the request failed due to a retryable error and retry attempts failed. |
ValueError | If the parameters are invalid. |
retry_build
retry_build(project_id, id_, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)
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.
.. rubric:: Example
from google.cloud.devtools import cloudbuild_v1
client = cloudbuild_v1.CloudBuildClient()
TODO: Initialize
project_id
:project_id = ''
TODO: Initialize
id_
:id_ = ''
response = client.retry_build(project_id, id_)
def callback(operation_future): ... # Handle result. ... result = operation_future.result()
response.add_done_callback(callback)
Handle metadata.
metadata = response.metadata()
Name | Description |
project_id |
str
Required. ID of the project. |
id_ |
str
Required. Build ID of the original build. |
retry |
Optional[google.api_core.retry.Retry]
A retry object used to retry requests. If |
timeout |
Optional[float]
The amount of time, in seconds, to wait for the request to complete. Note that if |
metadata |
Optional[Sequence[Tuple[str, str]]]
Additional metadata that is provided to the method. |
Type | Description |
google.api_core.exceptions.GoogleAPICallError | If the request failed for any reason. |
google.api_core.exceptions.RetryError | If the request failed due to a retryable error and retry attempts failed. |
ValueError | If the parameters are invalid. |
run_build_trigger
run_build_trigger(project_id, trigger_id, source, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)
Runs a BuildTrigger
at a particular source revision.
.. rubric:: Example
from google.cloud.devtools import cloudbuild_v1
client = cloudbuild_v1.CloudBuildClient()
TODO: Initialize
project_id
:project_id = ''
TODO: Initialize
trigger_id
:trigger_id = ''
TODO: Initialize
source
:source = {}
response = client.run_build_trigger(project_id, trigger_id, source)
def callback(operation_future): ... # Handle result. ... result = operation_future.result()
response.add_done_callback(callback)
Handle metadata.
metadata = response.metadata()
Name | Description |
project_id |
str
Required. ID of the project. |
trigger_id |
str
Required. ID of the trigger. |
source |
Union[dict, RepoSource]
Required. Source to build against this trigger. If a dict is provided, it must be of the same form as the protobuf message RepoSource |
retry |
Optional[google.api_core.retry.Retry]
A retry object used to retry requests. If |
timeout |
Optional[float]
The amount of time, in seconds, to wait for the request to complete. Note that if |
metadata |
Optional[Sequence[Tuple[str, str]]]
Additional metadata that is provided to the method. |
Type | Description |
google.api_core.exceptions.GoogleAPICallError | If the request failed for any reason. |
google.api_core.exceptions.RetryError | If the request failed due to a retryable error and retry attempts failed. |
ValueError | If the parameters are invalid. |
update_build_trigger
update_build_trigger(project_id, trigger_id, trigger, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)
Updates a BuildTrigger
by its project ID and trigger ID.
This API is experimental.
.. rubric:: Example
from google.cloud.devtools import cloudbuild_v1
client = cloudbuild_v1.CloudBuildClient()
TODO: Initialize
project_id
:project_id = ''
TODO: Initialize
trigger_id
:trigger_id = ''
TODO: Initialize
trigger
:trigger = {}
response = client.update_build_trigger(project_id, trigger_id, trigger)
Name | Description |
project_id |
str
Required. ID of the project that owns the trigger. |
trigger_id |
str
Required. ID of the |
trigger |
Union[dict, BuildTrigger]
Required. |
retry |
Optional[google.api_core.retry.Retry]
A retry object used to retry requests. If |
timeout |
Optional[float]
The amount of time, in seconds, to wait for the request to complete. Note that if |
metadata |
Optional[Sequence[Tuple[str, str]]]
Additional metadata that is provided to the method. |
Type | Description |
google.api_core.exceptions.GoogleAPICallError | If the request failed for any reason. |
google.api_core.exceptions.RetryError | If the request failed due to a retryable error and retry attempts failed. |
ValueError | If the parameters are invalid. |
update_worker_pool
update_worker_pool(name=None, worker_pool=None, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)
Update a WorkerPool
.
This API is experimental.
.. rubric:: Example
from google.cloud.devtools import cloudbuild_v1
client = cloudbuild_v1.CloudBuildClient()
response = client.update_worker_pool()
Name | Description |
name |
str
The field will contain name of the resource requested, for example: "projects/project-1/workerPools/workerpool-name" |
worker_pool |
Union[dict, WorkerPool]
|
retry |
Optional[google.api_core.retry.Retry]
A retry object used to retry requests. If |
timeout |
Optional[float]
The amount of time, in seconds, to wait for the request to complete. Note that if |
metadata |
Optional[Sequence[Tuple[str, str]]]
Additional metadata that is provided to the method. |
Type | Description |
google.api_core.exceptions.GoogleAPICallError | If the request failed for any reason. |
google.api_core.exceptions.RetryError | If the request failed due to a retryable error and retry attempts failed. |
ValueError | If the parameters are invalid. |