Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

AWS CodeBuild action using ADK

Focus mode
AWS CodeBuild action using ADK - Amazon CodeCatalyst

The following example action initiates a build in AWS CodeBuild. CodeBuild is an AWS service that compiles source code, runs tests, and packages the code into artifacts. For more information, see the AWS CodeBuild Documentation.

This action invokes the AWS Command Line Interface (AWS CLI), which is preinstalled on the action's runtime environment image within CodeCatalyst. The output of the CLI command is streamed to the console using stdout. For more information about what tools are installed on the runtime image, see Curated images.

Prerequisites

Complete all of the steps in Getting started with the Action Development Kit before moving on with developing the action.

Languages and toolchains

In this example, we'll develop an action using npm and TypeScript.

Update the action definition

Update the action definition (action.yml) that was generated in Step 3: Initialize your action project with the following AWSCodeBuildProject and AWSRegion input parameters:

SchemaVersion: '1.0' Name: 'AWSCodeBuildAction Action' Version: '0.0.0' Description: 'This Action starts a build in CodeBuild' Configuration: AWSCodeBuildProject: Description: 'Project name for AWS CodeBuild project' Required: true DisplayName: 'AWSCodeBuildProject' Type: string AWSRegion: Description: 'AWS Region' Required: false DisplayName: 'AWSRegion' Type: string Environment: Required: true Runs: Using: 'node16' Main: 'dist/index.js'

Update the action code

Update the entry point code in the lib/index.ts file that was generated in Step 4: Bootstrap the action code:

// @ts-ignore import * as core from '@aws/codecatalyst-adk-core'; // @ts-ignore import * as codecatalystProject from '@aws/codecatalyst-project'; // @ts-ignore import * as codecatalystSpace from '@aws/codecatalyst-space'; try { // Get inputs from the action const input_AWSCodeBuildProject = core.getInput('AWSCodeBuildProject'); // Project name for AWS CodeBuild project console.log(input_AWSCodeBuildProject); const input_AWSRegion = core.getInput('AWSRegion'); // AWS Region console.log(input_AWSRegion); // Interact with codecatalyst entities console.log(`Current CodeCatalyst space ${codecatalystSpace.getSpace().name}`); console.log(`Current codecatalyst project ${codecatalystProject.getProject().name}`); console.log(`AWS Region ${input_AWSRegion}`); // Action Code start console.log(core.command(`aws codebuild start-build --project-name ${input_AWSCodeBuildProject}`)); // Set outputs of the action } catch(error) { core.setFailed(`Action Failed, reason: ${error}`); }

After bootstrapping and updating the action code, continue with Step 4: Bootstrap the action code to complete the local build.

Validate the action within the CodeCatalyst workflow

After Testing an action, validate the action.

To validate the action

  1. Open the CodeCatalyst console at https://codecatalyst.aws/.

  2. Navigate to your project.

  3. In the navigation pane, choose CI/CD, and then choose Workflows.

  4. Choose the workflow with the action that you want to validate, then view Logs to confirm a successful run.

PrivacySite termsCookie preferences
© 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved.