aws-cdk-lib.aws_codebuild.IProject

interface IProject

LanguageType name
.NETAmazon.CDK.AWS.CodeBuild.IProject
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awscodebuild#IProject
Javasoftware.amazon.awscdk.services.codebuild.IProject
Pythonaws_cdk.aws_codebuild.IProject
TypeScript (source)aws-cdk-lib » aws_codebuild » IProject

Implemented by PipelineProject, Project

Obtainable from Project.fromProjectArn(), Project.fromProjectName()

Properties

NameTypeDescription
connectionsConnectionsThe network connections associated with this resource.
envResourceEnvironmentThe environment this resource belongs to.
grantPrincipalIPrincipalThe principal to grant permissions to.
nodeNodeThe tree node.
projectArnstringThe ARN of this Project.
projectNamestringThe human-visible name of this Project.
stackStackThe stack in which this resource is defined.
role?IRoleThe IAM service Role of this Project.

connections

Type: Connections

The network connections associated with this resource.


env

Type: ResourceEnvironment

The environment this resource belongs to.

For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that might be different than the stack they were imported into.


grantPrincipal

Type: IPrincipal

The principal to grant permissions to.


node

Type: Node

The tree node.


projectArn

Type: string

The ARN of this Project.


projectName

Type: string

The human-visible name of this Project.


stack

Type: Stack

The stack in which this resource is defined.


role?

Type: IRole (optional)

The IAM service Role of this Project.

Undefined for imported Projects.

Methods

NameDescription
addToRolePolicy(policyStatement)
applyRemovalPolicy(policy)Apply the given removal policy to this resource.
bindAsNotificationRuleSource(scope)Returns a source configuration for notification rule.
enableBatchBuilds()Enable batch builds.
metric(metricName, props?)
metricBuilds(props?)Measures the number of builds triggered.
metricDuration(props?)Measures the duration of all builds over time.
metricFailedBuilds(props?)Measures the number of builds that failed because of client error or because of a timeout.
metricSucceededBuilds(props?)Measures the number of successful builds.
notifyOn(id, target, options)Defines a CodeStar Notification rule triggered when the project events emitted by you specified, it very similar to onEvent API.
notifyOnBuildFailed(id, target, options?)Defines a CodeStar notification rule which triggers when a build fails.
notifyOnBuildSucceeded(id, target, options?)Defines a CodeStar notification rule which triggers when a build completes successfully.
onBuildFailed(id, options?)Defines an event rule which triggers when a build fails.
onBuildStarted(id, options?)Defines an event rule which triggers when a build starts.
onBuildSucceeded(id, options?)Defines an event rule which triggers when a build completes successfully.
onEvent(id, options?)Defines a CloudWatch event rule triggered when something happens with this project.
onPhaseChange(id, options?)Defines a CloudWatch event rule that triggers upon phase change of this build project.
onStateChange(id, options?)Defines a CloudWatch event rule triggered when the build project state changes.

addToRolePolicy(policyStatement)

public addToRolePolicy(policyStatement: PolicyStatement): void

Parameters

  • policyStatement PolicyStatement

applyRemovalPolicy(policy)

public applyRemovalPolicy(policy: RemovalPolicy): void

Parameters

  • policy RemovalPolicy

Apply the given removal policy to this resource.

The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.

The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN).


bindAsNotificationRuleSource(scope)

public bindAsNotificationRuleSource(scope: Construct): NotificationRuleSourceConfig

Parameters

  • scope Construct

Returns

  • NotificationRuleSourceConfig

Returns a source configuration for notification rule.


enableBatchBuilds()

public enableBatchBuilds(): BatchBuildConfig

Returns

  • BatchBuildConfig

Enable batch builds.

Returns an object contining the batch service role if batch builds could be enabled.


metric(metricName, props?)

public metric(metricName: string, props?: MetricOptions): Metric

Parameters

  • metricName string — The name of the metric.
  • props MetricOptions — Customization properties.

Returns

  • Metric

metricBuilds(props?)

public metricBuilds(props?: MetricOptions): Metric

Parameters

  • props MetricOptions

Returns

  • Metric

Measures the number of builds triggered.

Units: Count

Valid CloudWatch statistics: Sum


metricDuration(props?)

public metricDuration(props?: MetricOptions): Metric

Parameters

  • props MetricOptions

Returns

  • Metric

Measures the duration of all builds over time.

Units: Seconds

Valid CloudWatch statistics: Average (recommended), Maximum, Minimum


metricFailedBuilds(props?)

public metricFailedBuilds(props?: MetricOptions): Metric

Parameters

  • props MetricOptions

Returns

  • Metric

Measures the number of builds that failed because of client error or because of a timeout.

Units: Count

Valid CloudWatch statistics: Sum


metricSucceededBuilds(props?)

public metricSucceededBuilds(props?: MetricOptions): Metric

Parameters

  • props MetricOptions

Returns

  • Metric

Measures the number of successful builds.

Units: Count

Valid CloudWatch statistics: Sum


notifyOn(id, target, options)

public notifyOn(id: string, target: INotificationRuleTarget, options: ProjectNotifyOnOptions): INotificationRule

Parameters

  • id string — The logical identifier of the CodeStar Notifications rule that will be created.
  • target INotificationRuleTarget — The target to register for the CodeStar Notifications destination.
  • options ProjectNotifyOnOptions — Customization options for CodeStar Notifications rule.

Returns

  • INotificationRule

Defines a CodeStar Notification rule triggered when the project events emitted by you specified, it very similar to onEvent API.

You can also use the methods notifyOnBuildSucceeded and notifyOnBuildFailed to define rules for these specific event emitted.


notifyOnBuildFailed(id, target, options?)

public notifyOnBuildFailed(id: string, target: INotificationRuleTarget, options?: NotificationRuleOptions): INotificationRule

Parameters

  • id string
  • target INotificationRuleTarget
  • options NotificationRuleOptions

Returns

  • INotificationRule

Defines a CodeStar notification rule which triggers when a build fails.


notifyOnBuildSucceeded(id, target, options?)

public notifyOnBuildSucceeded(id: string, target: INotificationRuleTarget, options?: NotificationRuleOptions): INotificationRule

Parameters

  • id string
  • target INotificationRuleTarget
  • options NotificationRuleOptions

Returns

  • INotificationRule

Defines a CodeStar notification rule which triggers when a build completes successfully.


onBuildFailed(id, options?)

public onBuildFailed(id: string, options?: OnEventOptions): Rule

Parameters

  • id string
  • options OnEventOptions

Returns

  • Rule

Defines an event rule which triggers when a build fails.


onBuildStarted(id, options?)

public onBuildStarted(id: string, options?: OnEventOptions): Rule

Parameters

  • id string
  • options OnEventOptions

Returns

  • Rule

Defines an event rule which triggers when a build starts.


onBuildSucceeded(id, options?)

public onBuildSucceeded(id: string, options?: OnEventOptions): Rule

Parameters

  • id string
  • options OnEventOptions

Returns

  • Rule

Defines an event rule which triggers when a build completes successfully.


onEvent(id, options?)

public onEvent(id: string, options?: OnEventOptions): Rule

Parameters

  • id string
  • options OnEventOptions

Returns

  • Rule

Defines a CloudWatch event rule triggered when something happens with this project.

See also: https://docs.aws.amazon.com/codebuild/latest/userguide/sample-build-notifications.html


onPhaseChange(id, options?)

public onPhaseChange(id: string, options?: OnEventOptions): Rule

Parameters

  • id string
  • options OnEventOptions

Returns

  • Rule

Defines a CloudWatch event rule that triggers upon phase change of this build project.

See also: https://docs.aws.amazon.com/codebuild/latest/userguide/sample-build-notifications.html


onStateChange(id, options?)

public onStateChange(id: string, options?: OnEventOptions): Rule

Parameters

  • id string
  • options OnEventOptions

Returns

  • Rule

Defines a CloudWatch event rule triggered when the build project state changes.

You can filter specific build status events using an event pattern filter on the build-status detail field:

const rule = project.onStateChange('OnBuildStarted', { target }); rule.addEventPattern({ detail: { 'build-status': [ "IN_PROGRESS", "SUCCEEDED", "FAILED", "STOPPED" ] } });

You can also use the methods onBuildFailed and onBuildSucceeded to define rules for these specific state changes.

To access fields from the event in the event target input, use the static fields on the StateChangeEvent class.

See also: https://docs.aws.amazon.com/codebuild/latest/userguide/sample-build-notifications.html