Skip to content

GCP.CloudBuild reference

Source: src/GCP/CloudBuild/AccessReadToken.ts

Runtime binding for Cloud Build v2 repositories.accessReadToken.

Bind this operation to a Repository in a Function/Action init phase. Provide AccessReadTokenHttp. Returns a short-lived token that can clone the remote Git repository.

const accessReadToken = yield* GCP.CloudBuild.AccessReadToken(source);
const { token, expirationTime } = yield* accessReadToken();

Source: src/GCP/CloudBuild/AccessReadTokenHttp.ts Kind: Layer · Provides: GCP.CloudBuild.AccessReadToken

HTTP implementation of AccessReadToken.

Source: src/GCP/CloudBuild/AccessReadWriteToken.ts

Runtime binding for Cloud Build v2 repositories.accessReadWriteToken.

Bind this operation to a Repository in a Function/Action init phase. Provide AccessReadWriteTokenHttp. Returns a short-lived token that can clone and push to the remote Git repository.

AccessReadWriteToken: Fetching a Read/Write Token

Section titled “AccessReadWriteToken: Fetching a Read/Write Token”
const accessReadWriteToken = yield* GCP.CloudBuild.AccessReadWriteToken(source);
const { token, expirationTime } = yield* accessReadWriteToken();

Source: src/GCP/CloudBuild/AccessReadWriteTokenHttp.ts Kind: Layer · Provides: GCP.CloudBuild.AccessReadWriteToken

HTTP implementation of AccessReadWriteToken.

Source: src/GCP/CloudBuild/Connection.ts

A Cloud Build v2 connection to a source-control host (GitHub, GitHub Enterprise, GitLab, Bitbucket Data Center, or Bitbucket Cloud).

Changing connectionId or location replaces the connection. Switching SCM kinds, or changing immutable host fields (hostUri, workspace, webhookSecretSecretVersion), also replaces. disabled and annotations update in place.

Cloud Build connections have no labels. Alchemy stores ownership in annotations (alchemy-stack / alchemy-stage / alchemy-id) so list / pnpm nuke:gcp can find them.

Generated GitHub connection

const github = yield* GCP.CloudBuild.Connection("Github", {
githubConfig: {},
});

Named GitHub connection with installation

const github = yield* GCP.CloudBuild.Connection("Github", {
connectionId: "app-github",
location: "us-central1",
annotations: { env: "prod" },
githubConfig: {
appInstallationId: "123456",
authorizerCredential: {
oauthTokenSecretVersion:
"projects/{project}/secrets/github-pat/versions/latest",
},
},
});
const github = yield* GCP.CloudBuild.Connection("Github", {
connectionId: "app-github",
githubConfig: {},
disabled: true,
});
const gitlab = yield* GCP.CloudBuild.Connection("Gitlab", {
gitlabConfig: {
webhookSecretSecretVersion:
"projects/{project}/secrets/gitlab-webhook/versions/latest",
readAuthorizerCredential: {
userTokenSecretVersion:
"projects/{project}/secrets/gitlab-read/versions/latest",
},
authorizerCredential: {
userTokenSecretVersion:
"projects/{project}/secrets/gitlab-api/versions/latest",
},
},
});

Source: src/GCP/CloudBuild/FetchGitRefs.ts

Runtime binding for Cloud Build v2 repositories.fetchGitRefs.

Bind this operation to a Repository in a Function/Action init phase. Provide FetchGitRefsHttp.

Fetch branch names

const fetchGitRefs = yield* GCP.CloudBuild.FetchGitRefs(source);
const { refNames } = yield* fetchGitRefs({ refType: "BRANCH" });

Fetch tags

const { refNames } = yield* fetchGitRefs({ refType: "TAG", pageSize: 50 });

Source: src/GCP/CloudBuild/FetchGitRefsHttp.ts Kind: Layer · Provides: GCP.CloudBuild.FetchGitRefs

HTTP implementation of FetchGitRefs.

Source: src/GCP/CloudBuild/Repository.ts

A Cloud Build v2 repository — links a remote Git repository to a Connection.

Changing repositoryId, connection, location, remoteUri, or annotations replaces the repository. There is no update API; every user-facing field is immutable.

Cloud Build repositories have no labels. Alchemy stores ownership in annotations (alchemy-stack / alchemy-stage / alchemy-id) so list / pnpm nuke:gcp can find them.

Generated name

const github = yield* GCP.CloudBuild.Connection("Github", {
githubConfig: {},
});
const source = yield* GCP.CloudBuild.Repository("Source", {
connection: github.name,
remoteUri: "https://github.com/{owner}/{repo}.git",
});

Named repository with annotations

const source = yield* GCP.CloudBuild.Repository("Source", {
connection: github.name,
repositoryId: "app-source",
remoteUri: "https://github.com/{owner}/{repo}.git",
annotations: { env: "prod" },
});
const fetchGitRefs = yield* GCP.CloudBuild.FetchGitRefs(source);
const { refNames } = yield* fetchGitRefs({ refType: "BRANCH" });
const accessReadToken = yield* GCP.CloudBuild.AccessReadToken(source);
const { token } = yield* accessReadToken();