AWS.CodeBuild reference
BatchDeleteBuilds
Section titled “BatchDeleteBuilds”Source:
src/AWS/CodeBuild/BatchDeleteBuilds.ts
Runtime binding for codebuild:BatchDeleteBuilds — deletes builds of
the bound project by id. Builds that cannot be deleted are returned in
buildsNotDeleted with a reason rather than failing the call.
BatchDeleteBuilds: Deleting Builds
Section titled “BatchDeleteBuilds: Deleting Builds”const batchDeleteBuilds = yield* AWS.CodeBuild.BatchDeleteBuilds(project);
const { buildsDeleted, buildsNotDeleted } = yield* batchDeleteBuilds({ ids: oldBuildIds,});BatchGetBuildBatches
Section titled “BatchGetBuildBatches”Source:
src/AWS/CodeBuild/BatchGetBuildBatches.ts
Runtime binding for codebuild:BatchGetBuildBatches — reads the status
of one or more batch builds of the bound project by batch id.
BatchGetBuildBatches: Batch Builds
Section titled “BatchGetBuildBatches: Batch Builds”const batchGetBuildBatches = yield* AWS.CodeBuild.BatchGetBuildBatches(project);
const { buildBatches } = yield* batchGetBuildBatches({ ids: [batchId] });BatchGetBuilds
Section titled “BatchGetBuilds”Source:
src/AWS/CodeBuild/BatchGetBuilds.ts
Runtime binding for codebuild:BatchGetBuilds — reads the status of one
or more builds by id (the ids returned from StartBuild). Bind it
to the project whose builds you poll.
BatchGetBuilds: Polling Builds
Section titled “BatchGetBuilds: Polling Builds”const batchGetBuilds = yield* AWS.CodeBuild.BatchGetBuilds(project);
const { builds } = yield* batchGetBuilds({ ids: [buildId] });const status = builds?.[0]?.buildStatus; // IN_PROGRESS | SUCCEEDED | FAILED | ...BatchGetCommandExecutions
Section titled “BatchGetCommandExecutions”Source:
src/AWS/CodeBuild/BatchGetCommandExecutions.ts
Runtime binding for codebuild:BatchGetCommandExecutions — reads the
status and output of sandbox command executions of the bound project.
BatchGetCommandExecutions: Sandboxes
Section titled “BatchGetCommandExecutions: Sandboxes”const batchGetCommandExecutions = yield* AWS.CodeBuild.BatchGetCommandExecutions(project);
const { commandExecutions } = yield* batchGetCommandExecutions({ sandboxId, commandExecutionIds: [commandId],});BatchGetReports
Section titled “BatchGetReports”Source:
src/AWS/CodeBuild/BatchGetReports.ts
Runtime binding for codebuild:BatchGetReports — reads one or more
reports of the bound report group by report ARN.
BatchGetReports: Reading Reports
Section titled “BatchGetReports: Reading Reports”const batchGetReports = yield* AWS.CodeBuild.BatchGetReports(reportGroup);
const { reports } = yield* batchGetReports({ reportArns });BatchGetSandboxes
Section titled “BatchGetSandboxes”Source:
src/AWS/CodeBuild/BatchGetSandboxes.ts
Runtime binding for codebuild:BatchGetSandboxes — reads the status of
one or more sandboxes of the bound project by sandbox id.
BatchGetSandboxes: Sandboxes
Section titled “BatchGetSandboxes: Sandboxes”const batchGetSandboxes = yield* AWS.CodeBuild.BatchGetSandboxes(project);
const { sandboxes } = yield* batchGetSandboxes({ ids: [sandboxId] });DeleteBuildBatch
Section titled “DeleteBuildBatch”Source:
src/AWS/CodeBuild/DeleteBuildBatch.ts
Runtime binding for codebuild:DeleteBuildBatch — deletes a batch build
of the bound project (and its child builds) by batch id.
DeleteBuildBatch: Batch Builds
Section titled “DeleteBuildBatch: Batch Builds”const deleteBuildBatch = yield* AWS.CodeBuild.DeleteBuildBatch(project);
yield* deleteBuildBatch({ id: batchId });DeleteReport
Section titled “DeleteReport”Source:
src/AWS/CodeBuild/DeleteReport.ts
Runtime binding for codebuild:DeleteReport — deletes a report of the
bound report group by report ARN.
DeleteReport: Reading Reports
Section titled “DeleteReport: Reading Reports”const deleteReport = yield* AWS.CodeBuild.DeleteReport(reportGroup);
yield* deleteReport({ arn: reportArn });DescribeCodeCoverages
Section titled “DescribeCodeCoverages”Source:
src/AWS/CodeBuild/DescribeCodeCoverages.ts
Runtime binding for codebuild:DescribeCodeCoverages — reads the
per-file line/branch coverage of a coverage report in the bound report
group.
DescribeCodeCoverages: Reading Reports
Section titled “DescribeCodeCoverages: Reading Reports”const describeCodeCoverages = yield* AWS.CodeBuild.DescribeCodeCoverages(reportGroup);
const { codeCoverages } = yield* describeCodeCoverages({ reportArn });DescribeTestCases
Section titled “DescribeTestCases”Source:
src/AWS/CodeBuild/DescribeTestCases.ts
Runtime binding for codebuild:DescribeTestCases — reads the individual
test cases of a test report in the bound report group.
DescribeTestCases: Reading Reports
Section titled “DescribeTestCases: Reading Reports”const describeTestCases = yield* AWS.CodeBuild.DescribeTestCases(reportGroup);
const { testCases } = yield* describeTestCases({ reportArn, filter: { status: "FAILED" },});GetReportGroupTrend
Section titled “GetReportGroupTrend”Source:
src/AWS/CodeBuild/GetReportGroupTrend.ts
Runtime binding for codebuild:GetReportGroupTrend — aggregates a trend
statistic (pass rate, duration, …) across the bound report group’s most
recent reports.
GetReportGroupTrend: Reading Reports
Section titled “GetReportGroupTrend: Reading Reports”const getReportGroupTrend = yield* AWS.CodeBuild.GetReportGroupTrend(reportGroup);
const { stats } = yield* getReportGroupTrend({ trendField: "PASS_RATE" });InvalidateProjectCache
Section titled “InvalidateProjectCache”Source:
src/AWS/CodeBuild/InvalidateProjectCache.ts
Runtime binding for codebuild:InvalidateProjectCache — resets the
bound project’s build cache so the next build starts cold.
InvalidateProjectCache: Project Cache
Section titled “InvalidateProjectCache: Project Cache”const invalidateProjectCache = yield* AWS.CodeBuild.InvalidateProjectCache(project);
yield* invalidateProjectCache();ListBuildBatchesForProject
Section titled “ListBuildBatchesForProject”Source:
src/AWS/CodeBuild/ListBuildBatchesForProject.ts
Runtime binding for codebuild:ListBuildBatchesForProject — lists the
bound project’s batch build ids, optionally filtered by status.
ListBuildBatchesForProject: Batch Builds
Section titled “ListBuildBatchesForProject: Batch Builds”const listBuildBatches = yield* AWS.CodeBuild.ListBuildBatchesForProject(project);
const { ids } = yield* listBuildBatches();ListBuildsForProject
Section titled “ListBuildsForProject”Source:
src/AWS/CodeBuild/ListBuildsForProject.ts
Runtime binding for codebuild:ListBuildsForProject — lists the bound
project’s build ids, newest first. Page with nextToken; resolve ids to
statuses with BatchGetBuilds.
ListBuildsForProject: Listing Builds
Section titled “ListBuildsForProject: Listing Builds”const listBuilds = yield* AWS.CodeBuild.ListBuildsForProject(project);
const { ids } = yield* listBuilds();ListCommandExecutionsForSandbox
Section titled “ListCommandExecutionsForSandbox”Source:
src/AWS/CodeBuild/ListCommandExecutionsForSandbox.ts
Runtime binding for codebuild:ListCommandExecutionsForSandbox — lists
the command executions run in a sandbox of the bound project.
ListCommandExecutionsForSandbox: Sandboxes
Section titled “ListCommandExecutionsForSandbox: Sandboxes”const listCommandExecutions = yield* AWS.CodeBuild.ListCommandExecutionsForSandbox(project);
const { commandExecutions } = yield* listCommandExecutions({ sandboxId });ListReportsForReportGroup
Section titled “ListReportsForReportGroup”Source:
src/AWS/CodeBuild/ListReportsForReportGroup.ts
Runtime binding for codebuild:ListReportsForReportGroup — lists the
bound report group’s report ARNs, newest first.
ListReportsForReportGroup: Reading Reports
Section titled “ListReportsForReportGroup: Reading Reports”const listReports = yield* AWS.CodeBuild.ListReportsForReportGroup(reportGroup);
const { reports } = yield* listReports();ListSandboxesForProject
Section titled “ListSandboxesForProject”Source:
src/AWS/CodeBuild/ListSandboxesForProject.ts
Runtime binding for codebuild:ListSandboxesForProject — lists the
bound project’s sandbox ids, newest first.
ListSandboxesForProject: Sandboxes
Section titled “ListSandboxesForProject: Sandboxes”const listSandboxes = yield* AWS.CodeBuild.ListSandboxesForProject(project);
const { ids } = yield* listSandboxes();Project
Section titled “Project”Source:
src/AWS/CodeBuild/Project.ts
An AWS CodeBuild build project — a reusable definition of how to run a build: the source, the build container, the compute size, the IAM role, and where artifacts land.
The project is a definition only; creating it is instant and free.
Running a build (StartBuild) provisions compute and is billed per
build-minute.
Project: Creating a Project
Section titled “Project: Creating a Project”NO_SOURCE Project with an Inline Buildspec
const project = yield* CodeBuild.Project("Hello", { serviceRole: role.roleArn, source: { type: "NO_SOURCE", buildspec: [ "version: 0.2", "phases:", " build:", " commands:", " - echo Hello from CodeBuild", ].join("\n"), }, environment: { image: "aws/codebuild/amazonlinux2-x86_64-standard:5.0", computeType: "BUILD_GENERAL1_SMALL", },});S3-Source Project with S3 Artifacts
const project = yield* CodeBuild.Project("Packager", { serviceRole: role.roleArn, source: { type: "S3", location: `${bucket.bucketName}/source.zip` }, artifacts: { type: "S3", location: bucket.bucketName, name: "out.zip", packaging: "ZIP" }, environment: { image: "aws/codebuild/amazonlinux2-x86_64-standard:5.0", environmentVariables: [{ name: "STAGE", value: "prod" }], },});ReportGroup
Section titled “ReportGroup”Source:
src/AWS/CodeBuild/ReportGroup.ts
An AWS CodeBuild report group — a named collection of test or
code-coverage reports produced by builds. A build’s buildspec reports:
section uploads its test results into a report group, and the report-read
bindings (BatchGetReports, DescribeTestCases, …) let
runtime code query them.
ReportGroup: Creating a Report Group
Section titled “ReportGroup: Creating a Report Group”Test Report Group
const reports = yield* CodeBuild.ReportGroup("UnitTests", { type: "TEST",});Coverage Group Exported to S3
const coverage = yield* CodeBuild.ReportGroup("Coverage", { type: "CODE_COVERAGE", exportConfig: { exportConfigType: "S3", s3Destination: { bucket: bucket.bucketName, packaging: "ZIP" }, },});RetryBuild
Section titled “RetryBuild”Source:
src/AWS/CodeBuild/RetryBuild.ts
Runtime binding for codebuild:RetryBuild — restarts a finished
(failed, stopped, …) build of the bound project by build id, producing a
new build.
RetryBuild: Retrying Builds
Section titled “RetryBuild: Retrying Builds”const retryBuild = yield* AWS.CodeBuild.RetryBuild(project);
const { build } = yield* retryBuild({ id: failedBuildId });RetryBuildBatch
Section titled “RetryBuildBatch”Source:
src/AWS/CodeBuild/RetryBuildBatch.ts
Runtime binding for codebuild:RetryBuildBatch — restarts a finished
batch build of the bound project, retrying either all builds or only the
failed ones (retryType).
RetryBuildBatch: Batch Builds
Section titled “RetryBuildBatch: Batch Builds”const retryBuildBatch = yield* AWS.CodeBuild.RetryBuildBatch(project);
yield* retryBuildBatch({ id: batchId, retryType: "RETRY_FAILED_BUILDS" });StartBuild
Section titled “StartBuild”Source:
src/AWS/CodeBuild/StartBuild.ts
Runtime binding for codebuild:StartBuild — lets a workload kick off a
build of a CodeBuild project (optionally overriding the source version,
environment variables, buildspec, etc.).
The response carries the created build including its id, which can be
polled with the BatchGetBuilds binding.
StartBuild: Starting Builds
Section titled “StartBuild: Starting Builds”const startBuild = yield* AWS.CodeBuild.StartBuild(project);
const { build } = yield* startBuild({ environmentVariablesOverride: [ { name: "COMMIT", value: sha, type: "PLAINTEXT" }, ],});StartBuildBatch
Section titled “StartBuildBatch”Source:
src/AWS/CodeBuild/StartBuildBatch.ts
Runtime binding for codebuild:StartBuildBatch — kicks off a batch
(fan-out) build of the bound project. The project must have a build batch
configuration and the buildspec a batch: section.
StartBuildBatch: Batch Builds
Section titled “StartBuildBatch: Batch Builds”const startBuildBatch = yield* AWS.CodeBuild.StartBuildBatch(project);
const { buildBatch } = yield* startBuildBatch();StartCommandExecution
Section titled “StartCommandExecution”Source:
src/AWS/CodeBuild/StartCommandExecution.ts
Runtime binding for codebuild:StartCommandExecution — runs a shell
command in a running sandbox of the bound project. Poll the result with
BatchGetCommandExecutions.
StartCommandExecution: Sandboxes
Section titled “StartCommandExecution: Sandboxes”const startCommandExecution = yield* AWS.CodeBuild.StartCommandExecution(project);
const { commandExecution } = yield* startCommandExecution({ sandboxId, command: "echo hello",});StartSandbox
Section titled “StartSandbox”Source:
src/AWS/CodeBuild/StartSandbox.ts
Runtime binding for codebuild:StartSandbox — launches an interactive
sandbox environment for the bound project. Run commands in it with
StartCommandExecution; stop it with StopSandbox.
StartSandbox: Sandboxes
Section titled “StartSandbox: Sandboxes”const startSandbox = yield* AWS.CodeBuild.StartSandbox(project);
const { sandbox } = yield* startSandbox();StopBuild
Section titled “StopBuild”Source:
src/AWS/CodeBuild/StopBuild.ts
Runtime binding for codebuild:StopBuild — stops an in-progress build
of the bound project by build id.
StopBuild: Stopping Builds
Section titled “StopBuild: Stopping Builds”const stopBuild = yield* AWS.CodeBuild.StopBuild(project);
const { build } = yield* stopBuild({ id: buildId });// build.buildStatus transitions to "STOPPED"StopBuildBatch
Section titled “StopBuildBatch”Source:
src/AWS/CodeBuild/StopBuildBatch.ts
Runtime binding for codebuild:StopBuildBatch — stops an in-progress
batch build of the bound project by batch id.
StopBuildBatch: Batch Builds
Section titled “StopBuildBatch: Batch Builds”const stopBuildBatch = yield* AWS.CodeBuild.StopBuildBatch(project);
yield* stopBuildBatch({ id: batchId });StopSandbox
Section titled “StopSandbox”Source:
src/AWS/CodeBuild/StopSandbox.ts
Runtime binding for codebuild:StopSandbox — stops a running sandbox of
the bound project by sandbox id.
StopSandbox: Sandboxes
Section titled “StopSandbox: Sandboxes”const stopSandbox = yield* AWS.CodeBuild.StopSandbox(project);
yield* stopSandbox({ id: sandboxId });