gigl.common.services.cloud_build#
Cancel Cloud Build builds by tag through the google-cloud-build library.
Attributes#
Classes#
Lists and cancels Cloud Build builds in one project. |
Module Contents#
- class gigl.common.services.cloud_build.CloudBuildService(project)[source]#
Lists and cancels Cloud Build builds in one project.
Example
>>> service = CloudBuildService(project="p") >>> service.cancel_builds_with_tag("gigl-ci-run-123456") ['6c1d0e5a-0000-0000-0000-000000000000']
- Parameters:
project (str) – GCP project that owns the builds.
- cancel_builds_with_tag(tag)[source]#
Request a cancel for every queued or running build that carries
tag.Builds that already finished are left alone.
A failed cancel does not stop the loop. Every matching build gets a cancel request before the errors are raised.
Example
>>> CloudBuildService(project="p").cancel_builds_with_tag("gigl-ci-run-123456") ['6c1d0e5a-0000-0000-0000-000000000000']
- Parameters:
tag (str) – Cloud Build tag to match.
- Returns:
Ids of the builds a cancel was requested for, in listing order.
- Raises:
google.api_core.exceptions.GoogleAPICallError – If the list call fails.
ExceptionGroup – If one or more cancels failed. It holds one error for each failed build.
- Return type:
list[str]
- wait_for_builds_to_stop(build_ids, timeout_s, poll_interval_s=10.0)[source]#
Wait until none of the builds is pending, queued, or working.
A build can keep running for some seconds after a cancel request.
Example
>>> service.wait_for_builds_to_stop(["6c1d0e5a-..."], timeout_s=300)
- Parameters:
build_ids (Sequence[str]) – Ids of the builds to wait for.
timeout_s (float) – Seconds to wait before giving up.
poll_interval_s (float) – Seconds between status reads.
- Raises:
TimeoutError – If a build is still active after
timeout_s.- Return type:
None