Class Project
- All Implemented Interfaces:
IConstruct,IDependable,IResource,IProject,INotificationRuleSource,IConnectable,IGrantable,software.amazon.jsii.JsiiSerializable,software.constructs.IConstruct
- Direct Known Subclasses:
PipelineProject
Example:
Bucket bucket;
Project project = Project.Builder.create(this, "MyProject")
.buildSpec(BuildSpec.fromObject(Map.of(
"version", "0.2")))
.artifacts(Artifacts.s3(S3ArtifactsProps.builder()
.bucket(bucket)
.includeBuildId(false)
.packageZip(true)
.path("another/path")
.identifier("AddArtifact1")
.build()))
.build();
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationModeNested classes/interfaces inherited from interface software.amazon.awscdk.core.IConstruct
IConstruct.Jsii$DefaultNested classes/interfaces inherited from interface software.constructs.IConstruct
software.constructs.IConstruct.Jsii$DefaultNested classes/interfaces inherited from interface software.amazon.awscdk.services.codebuild.IProject
IProject.Jsii$Default, IProject.Jsii$ProxyNested classes/interfaces inherited from interface software.amazon.awscdk.core.IResource
IResource.Jsii$Default -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedProject(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protectedProject(software.amazon.jsii.JsiiObjectRef objRef) Project(software.constructs.Construct scope, String id, ProjectProps props) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddFileSystemLocation(IFileSystemLocation fileSystemLocation) Adds a fileSystemLocation to the Project.voidaddSecondaryArtifact(IArtifacts secondaryArtifact) Adds a secondary artifact to the Project.voidaddSecondarySource(ISource secondarySource) Adds a secondary source to the Project.voidaddToRolePolicy(PolicyStatement statement) Add a permission only if there's a policy attached.bindAsNotificationRuleSource(software.constructs.Construct _scope) Returns a source configuration for notification rule.voidbindToCodePipeline(Construct _scope, BindToCodePipelineOptions options) A callback invoked when the given project is added to a CodePipeline.Enable batch builds.static IProjectfromProjectArn(software.constructs.Construct scope, String id, String projectArn) static IProjectfromProjectName(software.constructs.Construct scope, String id, String projectName) Import a Project defined either outside the CDK, or in a different CDK Stack (and exported using theexportmethod).Access the Connections object.The principal to grant permissions to.The ARN of the project.The name of the project.getRole()The IAM role for this project.metric(String metricName, MetricOptions props) Measures the number of builds triggered.metricBuilds(MetricOptions props) Measures the number of builds triggered.Measures the duration of all builds over time.metricDuration(MetricOptions props) Measures the duration of all builds over time.Measures the number of builds that failed because of client error or because of a timeout.metricFailedBuilds(MetricOptions props) Measures the number of builds that failed because of client error or because of a timeout.Measures the number of successful builds.Measures the number of successful builds.notifyOn(String id, INotificationRuleTarget target, ProjectNotifyOnOptions options) Defines a CodeStar Notification rule triggered when the project events emitted by you specified, it very similar toonEventAPI.notifyOnBuildFailed(String id, INotificationRuleTarget target) Defines a CodeStar notification rule which triggers when a build fails.notifyOnBuildFailed(String id, INotificationRuleTarget target, NotificationRuleOptions options) Defines a CodeStar notification rule which triggers when a build fails.notifyOnBuildSucceeded(String id, INotificationRuleTarget target) Defines a CodeStar notification rule which triggers when a build completes successfully.notifyOnBuildSucceeded(String id, INotificationRuleTarget target, NotificationRuleOptions options) Defines a CodeStar notification rule which triggers when a build completes successfully.onBuildFailed(String id) Defines an event rule which triggers when a build fails.onBuildFailed(String id, OnEventOptions options) Defines an event rule which triggers when a build fails.onBuildStarted(String id) Defines an event rule which triggers when a build starts.onBuildStarted(String id, OnEventOptions options) Defines an event rule which triggers when a build starts.Defines an event rule which triggers when a build completes successfully.onBuildSucceeded(String id, OnEventOptions options) Defines an event rule which triggers when a build completes successfully.Defines a CloudWatch event rule triggered when something happens with this project.onEvent(String id, OnEventOptions options) Defines a CloudWatch event rule triggered when something happens with this project.onPhaseChange(String id) Defines a CloudWatch event rule that triggers upon phase change of this build project.onPhaseChange(String id, OnEventOptions options) Defines a CloudWatch event rule that triggers upon phase change of this build project.onStateChange(String id) Defines a CloudWatch event rule triggered when the build project state changes.onStateChange(String id, OnEventOptions options) Defines a CloudWatch event rule triggered when the build project state changes.serializeEnvVariables(Map<String, ? extends BuildEnvironmentVariable> environmentVariables) Convert the environment variables map of string toBuildEnvironmentVariable, which is the customer-facing type, to a list ofCfnProject.EnvironmentVariableProperty, which is the representation of environment variables in CloudFormation.serializeEnvVariables(Map<String, ? extends BuildEnvironmentVariable> environmentVariables, Boolean validateNoPlainTextSecrets) Convert the environment variables map of string toBuildEnvironmentVariable, which is the customer-facing type, to a list ofCfnProject.EnvironmentVariableProperty, which is the representation of environment variables in CloudFormation.serializeEnvVariables(Map<String, ? extends BuildEnvironmentVariable> environmentVariables, Boolean validateNoPlainTextSecrets, IGrantable principal) Convert the environment variables map of string toBuildEnvironmentVariable, which is the customer-facing type, to a list ofCfnProject.EnvironmentVariableProperty, which is the representation of environment variables in CloudFormation.validate()Validate the current construct.Methods inherited from class software.amazon.awscdk.core.Resource
applyRemovalPolicy, generatePhysicalName, getEnv, getPhysicalName, getResourceArnAttribute, getResourceNameAttribute, getStack, isResourceMethods inherited from class software.amazon.awscdk.core.Construct
getNode, isConstruct, onPrepare, onSynthesize, onValidate, prepare, synthesizeMethods inherited from class software.constructs.Construct
toStringMethods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSetMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface software.amazon.awscdk.core.IConstruct
getNodeMethods inherited from interface software.amazon.awscdk.core.IResource
applyRemovalPolicy, getEnv, getStackMethods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Constructor Details
-
Project
protected Project(software.amazon.jsii.JsiiObjectRef objRef) -
Project
protected Project(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) -
Project
@Stability(Stable) public Project(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull ProjectProps props) - Parameters:
scope- This parameter is required.id- This parameter is required.props- This parameter is required.
-
-
Method Details
-
fromProjectArn
@Stability(Stable) @NotNull public static IProject fromProjectArn(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull String projectArn) - Parameters:
scope- This parameter is required.id- This parameter is required.projectArn- This parameter is required.
-
fromProjectName
@Stability(Stable) @NotNull public static IProject fromProjectName(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull String projectName) Import a Project defined either outside the CDK, or in a different CDK Stack (and exported using theexportmethod).- Parameters:
scope- the parent Construct for this Construct. This parameter is required.id- the logical name of this Construct. This parameter is required.projectName- the name of the project to import. This parameter is required.- Returns:
- a reference to the existing Project
-
serializeEnvVariables
@Stability(Stable) @NotNull public static List<CfnProject.EnvironmentVariableProperty> serializeEnvVariables(@NotNull Map<String, ? extends BuildEnvironmentVariable> environmentVariables, @Nullable Boolean validateNoPlainTextSecrets, @Nullable IGrantable principal) Convert the environment variables map of string toBuildEnvironmentVariable, which is the customer-facing type, to a list ofCfnProject.EnvironmentVariableProperty, which is the representation of environment variables in CloudFormation.- Parameters:
environmentVariables- the map of string to environment variables. This parameter is required.validateNoPlainTextSecrets- whether to throw an exception if any of the plain text environment variables contain secrets, defaults to 'false'.principal-- Returns:
- an array of
CfnProject.EnvironmentVariablePropertyinstances
-
serializeEnvVariables
@Stability(Stable) @NotNull public static List<CfnProject.EnvironmentVariableProperty> serializeEnvVariables(@NotNull Map<String, ? extends BuildEnvironmentVariable> environmentVariables, @Nullable Boolean validateNoPlainTextSecrets) Convert the environment variables map of string toBuildEnvironmentVariable, which is the customer-facing type, to a list ofCfnProject.EnvironmentVariableProperty, which is the representation of environment variables in CloudFormation.- Parameters:
environmentVariables- the map of string to environment variables. This parameter is required.validateNoPlainTextSecrets- whether to throw an exception if any of the plain text environment variables contain secrets, defaults to 'false'.- Returns:
- an array of
CfnProject.EnvironmentVariablePropertyinstances
-
serializeEnvVariables
@Stability(Stable) @NotNull public static List<CfnProject.EnvironmentVariableProperty> serializeEnvVariables(@NotNull Map<String, ? extends BuildEnvironmentVariable> environmentVariables) Convert the environment variables map of string toBuildEnvironmentVariable, which is the customer-facing type, to a list ofCfnProject.EnvironmentVariableProperty, which is the representation of environment variables in CloudFormation.- Parameters:
environmentVariables- the map of string to environment variables. This parameter is required.- Returns:
- an array of
CfnProject.EnvironmentVariablePropertyinstances
-
addFileSystemLocation
@Stability(Stable) public void addFileSystemLocation(@NotNull IFileSystemLocation fileSystemLocation) Adds a fileSystemLocation to the Project.- Parameters:
fileSystemLocation- the fileSystemLocation to add. This parameter is required.
-
addSecondaryArtifact
Adds a secondary artifact to the Project.- Parameters:
secondaryArtifact- the artifact to add as a secondary artifact. This parameter is required.- See Also:
-
addSecondarySource
Adds a secondary source to the Project.- Parameters:
secondarySource- the source to add as a secondary source. This parameter is required.- See Also:
-
addToRolePolicy
Add a permission only if there's a policy attached.- Specified by:
addToRolePolicyin interfaceIProject- Parameters:
statement- The permissions statement to add. This parameter is required.
-
bindAsNotificationRuleSource
@Stability(Stable) @NotNull public NotificationRuleSourceConfig bindAsNotificationRuleSource(@NotNull software.constructs.Construct _scope) Returns a source configuration for notification rule.- Specified by:
bindAsNotificationRuleSourcein interfaceINotificationRuleSource- Parameters:
_scope- This parameter is required.
-
bindToCodePipeline
@Stability(Stable) public void bindToCodePipeline(@NotNull Construct _scope, @NotNull BindToCodePipelineOptions options) A callback invoked when the given project is added to a CodePipeline.- Parameters:
_scope- the construct the binding is taking place in. This parameter is required.options- additional options for the binding. This parameter is required.
-
enableBatchBuilds
Enable batch builds.Returns an object contining the batch service role if batch builds could be enabled.
- Specified by:
enableBatchBuildsin interfaceIProject
-
metric
@Stability(Stable) @NotNull public Metric metric(@NotNull String metricName, @Nullable MetricOptions props) -
metric
-
metricBuilds
Measures the number of builds triggered.Units: Count
Valid CloudWatch statistics: Sum
Default: sum over 5 minutes
- Specified by:
metricBuildsin interfaceIProject- Parameters:
props-
-
metricBuilds
Measures the number of builds triggered.Units: Count
Valid CloudWatch statistics: Sum
Default: sum over 5 minutes
- Specified by:
metricBuildsin interfaceIProject
-
metricDuration
Measures the duration of all builds over time.Units: Seconds
Valid CloudWatch statistics: Average (recommended), Maximum, Minimum
Default: average over 5 minutes
- Specified by:
metricDurationin interfaceIProject- Parameters:
props-
-
metricDuration
Measures the duration of all builds over time.Units: Seconds
Valid CloudWatch statistics: Average (recommended), Maximum, Minimum
Default: average over 5 minutes
- Specified by:
metricDurationin interfaceIProject
-
metricFailedBuilds
Measures the number of builds that failed because of client error or because of a timeout.Units: Count
Valid CloudWatch statistics: Sum
Default: sum over 5 minutes
- Specified by:
metricFailedBuildsin interfaceIProject- Parameters:
props-
-
metricFailedBuilds
Measures the number of builds that failed because of client error or because of a timeout.Units: Count
Valid CloudWatch statistics: Sum
Default: sum over 5 minutes
- Specified by:
metricFailedBuildsin interfaceIProject
-
metricSucceededBuilds
Measures the number of successful builds.Units: Count
Valid CloudWatch statistics: Sum
Default: sum over 5 minutes
- Specified by:
metricSucceededBuildsin interfaceIProject- Parameters:
props-
-
metricSucceededBuilds
Measures the number of successful builds.Units: Count
Valid CloudWatch statistics: Sum
Default: sum over 5 minutes
- Specified by:
metricSucceededBuildsin interfaceIProject
-
notifyOn
@Stability(Stable) @NotNull public INotificationRule notifyOn(@NotNull String id, @NotNull INotificationRuleTarget target, @NotNull ProjectNotifyOnOptions options) Defines a CodeStar Notification rule triggered when the project events emitted by you specified, it very similar toonEventAPI.You can also use the methods
notifyOnBuildSucceededandnotifyOnBuildFailedto define rules for these specific event emitted. -
notifyOnBuildFailed
@Stability(Stable) @NotNull public INotificationRule notifyOnBuildFailed(@NotNull String id, @NotNull INotificationRuleTarget target, @Nullable NotificationRuleOptions options) Defines a CodeStar notification rule which triggers when a build fails.- Specified by:
notifyOnBuildFailedin interfaceIProject- Parameters:
id- This parameter is required.target- This parameter is required.options-
-
notifyOnBuildFailed
@Stability(Stable) @NotNull public INotificationRule notifyOnBuildFailed(@NotNull String id, @NotNull INotificationRuleTarget target) Defines a CodeStar notification rule which triggers when a build fails.- Specified by:
notifyOnBuildFailedin interfaceIProject- Parameters:
id- This parameter is required.target- This parameter is required.
-
notifyOnBuildSucceeded
@Stability(Stable) @NotNull public INotificationRule notifyOnBuildSucceeded(@NotNull String id, @NotNull INotificationRuleTarget target, @Nullable NotificationRuleOptions options) Defines a CodeStar notification rule which triggers when a build completes successfully.- Specified by:
notifyOnBuildSucceededin interfaceIProject- Parameters:
id- This parameter is required.target- This parameter is required.options-
-
notifyOnBuildSucceeded
@Stability(Stable) @NotNull public INotificationRule notifyOnBuildSucceeded(@NotNull String id, @NotNull INotificationRuleTarget target) Defines a CodeStar notification rule which triggers when a build completes successfully.- Specified by:
notifyOnBuildSucceededin interfaceIProject- Parameters:
id- This parameter is required.target- This parameter is required.
-
onBuildFailed
@Stability(Stable) @NotNull public Rule onBuildFailed(@NotNull String id, @Nullable OnEventOptions options) Defines an event rule which triggers when a build fails.To access fields from the event in the event target input, use the static fields on the
StateChangeEventclass.- Specified by:
onBuildFailedin interfaceIProject- Parameters:
id- This parameter is required.options-
-
onBuildFailed
Defines an event rule which triggers when a build fails.To access fields from the event in the event target input, use the static fields on the
StateChangeEventclass.- Specified by:
onBuildFailedin interfaceIProject- Parameters:
id- This parameter is required.
-
onBuildStarted
@Stability(Stable) @NotNull public Rule onBuildStarted(@NotNull String id, @Nullable OnEventOptions options) Defines an event rule which triggers when a build starts.To access fields from the event in the event target input, use the static fields on the
StateChangeEventclass.- Specified by:
onBuildStartedin interfaceIProject- Parameters:
id- This parameter is required.options-
-
onBuildStarted
Defines an event rule which triggers when a build starts.To access fields from the event in the event target input, use the static fields on the
StateChangeEventclass.- Specified by:
onBuildStartedin interfaceIProject- Parameters:
id- This parameter is required.
-
onBuildSucceeded
@Stability(Stable) @NotNull public Rule onBuildSucceeded(@NotNull String id, @Nullable OnEventOptions options) Defines an event rule which triggers when a build completes successfully.To access fields from the event in the event target input, use the static fields on the
StateChangeEventclass.- Specified by:
onBuildSucceededin interfaceIProject- Parameters:
id- This parameter is required.options-
-
onBuildSucceeded
Defines an event rule which triggers when a build completes successfully.To access fields from the event in the event target input, use the static fields on the
StateChangeEventclass.- Specified by:
onBuildSucceededin interfaceIProject- Parameters:
id- This parameter is required.
-
onEvent
@Stability(Stable) @NotNull public Rule onEvent(@NotNull String id, @Nullable OnEventOptions options) Defines a CloudWatch event rule triggered when something happens with this project. -
onEvent
Defines a CloudWatch event rule triggered when something happens with this project. -
onPhaseChange
@Stability(Stable) @NotNull public Rule onPhaseChange(@NotNull String id, @Nullable OnEventOptions options) Defines a CloudWatch event rule that triggers upon phase change of this build project.- Specified by:
onPhaseChangein interfaceIProject- Parameters:
id- This parameter is required.options-- See Also:
-
onPhaseChange
Defines a CloudWatch event rule that triggers upon phase change of this build project.- Specified by:
onPhaseChangein interfaceIProject- Parameters:
id- This parameter is required.- See Also:
-
onStateChange
@Stability(Stable) @NotNull public Rule onStateChange(@NotNull String id, @Nullable OnEventOptions options) 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-statusdetail field:const rule = project.onStateChange('OnBuildStarted', { target }); rule.addEventPattern({ detail: { 'build-status': [ "IN_PROGRESS", "SUCCEEDED", "FAILED", "STOPPED" ] } });You can also use the methods
onBuildFailedandonBuildSucceededto define rules for these specific state changes.To access fields from the event in the event target input, use the static fields on the
StateChangeEventclass.- Specified by:
onStateChangein interfaceIProject- Parameters:
id- This parameter is required.options-- See Also:
-
onStateChange
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-statusdetail field:const rule = project.onStateChange('OnBuildStarted', { target }); rule.addEventPattern({ detail: { 'build-status': [ "IN_PROGRESS", "SUCCEEDED", "FAILED", "STOPPED" ] } });You can also use the methods
onBuildFailedandonBuildSucceededto define rules for these specific state changes.To access fields from the event in the event target input, use the static fields on the
StateChangeEventclass.- Specified by:
onStateChangein interfaceIProject- Parameters:
id- This parameter is required.- See Also:
-
validate
Validate the current construct.This method can be implemented by derived constructs in order to perform validation logic. It is called on all constructs before synthesis.
-
getConnections
Access the Connections object.Will fail if this Project does not have a VPC set.
- Specified by:
getConnectionsin interfaceIConnectable
-
getGrantPrincipal
The principal to grant permissions to.- Specified by:
getGrantPrincipalin interfaceIGrantable
-
getProjectArn
The ARN of the project.- Specified by:
getProjectArnin interfaceIProject
-
getProjectName
The name of the project.- Specified by:
getProjectNamein interfaceIProject
-
getRole
The IAM role for this project.
-