interface IProject
Language | Type name |
---|---|
![]() | Amazon.CDK.AWS.CodeBuild.IProject |
![]() | software.amazon.awscdk.services.codebuild.IProject |
![]() | aws_cdk.aws_codebuild.IProject |
![]() | @aws-cdk/aws-codebuild » IProject |
Implemented by
Pipeline
, Project
Obtainable from
Project
.fromProjectArn()
, Project
.fromProjectName()
Properties
Name | Type | Description |
---|---|---|
connections | Connections | The network connections associated with this resource. |
env | Resource | The environment this resource belongs to. |
grant | IPrincipal | The principal to grant permissions to. |
node | Construct | The construct tree node for this construct. |
project | string | The ARN of this Project. |
project | string | The human-visible name of this Project. |
stack | Stack | The stack in which this resource is defined. |
role? | IRole | The IAM service Role of this Project. |
connections
Type:
Connections
The network connections associated with this resource.
env
Type:
Resource
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:
Construct
The construct tree node for this construct.
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
Name | Description |
---|---|
add | |
apply | Apply the given removal policy to this resource. |
bind | Returns a source configuration for notification rule. |
enable | Enable batch builds. |
metric(metricName, props?) | |
metric | Measures the number of builds triggered. |
metric | Measures the duration of all builds over time. |
metric | Measures the number of builds that failed because of client error or because of a timeout. |
metric | Measures the number of successful builds. |
notify | Defines a CodeStar Notification rule triggered when the project events emitted by you specified, it very similar to onEvent API. |
notify | Defines a CodeStar notification rule which triggers when a build fails. |
notify | Defines a CodeStar notification rule which triggers when a build completes successfully. |
on | Defines an event rule which triggers when a build fails. |
on | Defines an event rule which triggers when a build starts. |
on | Defines an event rule which triggers when a build completes successfully. |
on | Defines a CloudWatch event rule triggered when something happens with this project. |
on | Defines a CloudWatch event rule that triggers upon phase change of this build project. |
on | Defines a CloudWatch event rule triggered when the build project state changes. |
addToRolePolicy(policyStatement)
public addToRolePolicy(policyStatement: PolicyStatement): void
Parameters
- policyStatement
Policy
Statement
applyRemovalPolicy(policy)
public applyRemovalPolicy(policy: RemovalPolicy): void
Parameters
- policy
Removal
Policy
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
Returns a source configuration for notification rule.
enableBatchBuilds()
public enableBatchBuilds(): BatchBuildConfig
Returns
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
Metric
— Customization properties.Options
Returns
metricBuilds(props?)
public metricBuilds(props?: MetricOptions): Metric
Parameters
- props
Metric
Options
Returns
Measures the number of builds triggered.
Units: Count
Valid CloudWatch statistics: Sum
metricDuration(props?)
public metricDuration(props?: MetricOptions): Metric
Parameters
- props
Metric
Options
Returns
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
Metric
Options
Returns
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
Metric
Options
Returns
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
INotification
— The target to register for the CodeStar Notifications destination.Rule Target - options
Project
— Customization options for CodeStar Notifications rule.Notify On Options
Returns
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
INotification
Rule Target - options
Notification
Rule Options
Returns
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
INotification
Rule Target - options
Notification
Rule Options
Returns
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
On
Event Options
Returns
Defines an event rule which triggers when a build fails.
onBuildStarted(id, options?)
public onBuildStarted(id: string, options?: OnEventOptions): Rule
Parameters
- id
string
- options
On
Event Options
Returns
Defines an event rule which triggers when a build starts.
onBuildSucceeded(id, options?)
public onBuildSucceeded(id: string, options?: OnEventOptions): Rule
Parameters
- id
string
- options
On
Event Options
Returns
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
On
Event Options
Returns
Defines a CloudWatch event rule triggered when something happens with this project.
onPhaseChange(id, options?)
public onPhaseChange(id: string, options?: OnEventOptions): Rule
Parameters
- id
string
- options
On
Event Options
Returns
Defines a CloudWatch event rule that triggers upon phase change of this build project.
onStateChange(id, options?)
public onStateChange(id: string, options?: OnEventOptions): Rule
Parameters
- id
string
- options
On
Event Options
Returns
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.