Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Cloud Build Quickstart

import google.auth
from google.cloud.devtools import cloudbuild_v1


def quickstart():
    """Create and execute a simple Google Cloud Build configuration,
    print the in-progress status and print the completed status."""

    # Authorize the client with Google defaults
    credentials, project_id = google.auth.default()
    client = cloudbuild_v1.services.cloud_build.CloudBuildClient()

    build = cloudbuild_v1.Build()

    # The following build steps will output "hello world"
    # For more information on build configuration, see
    # https://cloud.google.com/build/docs/configuring-builds/create-basic-configuration
    build.steps = [{"name": "ubuntu",
                    "entrypoint": "bash",
                    "args": ["-c", "echo hello world"]}]

    operation = client.create_build(project_id=project_id, build=build)
    # Print the in-progress operation
    print("IN PROGRESS:")
    print(operation.metadata)

    result = operation.result()
    # Print the completed status
    print("RESULT:", result.status)
Source by www.codegrepper.com #
 
PREVIOUS NEXT
Tagged: #Cloud #Build #Quickstart
ADD COMMENT
Topic
Name
7+9 =