java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
software.amazon.awscdk.Resource
software.amazon.awscdk.services.codebuild.Project
All Implemented Interfaces:
IResource, IProject, INotificationRuleSource, IConnectable, IGrantable, software.amazon.jsii.JsiiSerializable, software.constructs.IConstruct, software.constructs.IDependable
Direct Known Subclasses:
PipelineProject

@Generated(value="jsii-pacmak/1.98.0 (build 00b106d)", date="2024-05-02T15:58:22.896Z") @Stability(Stable) public class Project extends Resource implements IProject
A representation of a CodeBuild Project.

Example:

 Repository ecrRepository;
 Project.Builder.create(this, "Project")
         .environment(BuildEnvironment.builder()
                 .buildImage(WindowsBuildImage.fromEcrRepository(ecrRepository, "v1.0", WindowsImageType.SERVER_2019))
                 // optional certificate to include in the build image
                 .certificate(BuildEnvironmentCertificate.builder()
                         .bucket(Bucket.fromBucketName(this, "Bucket", "my-bucket"))
                         .objectKey("path/to/cert.pem")
                         .build())
                 .build())
         .build();
 
  • 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 the export method).

      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 to BuildEnvironmentVariable, which is the customer-facing type, to a list of CfnProject.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.EnvironmentVariableProperty instances
    • 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 to BuildEnvironmentVariable, which is the customer-facing type, to a list of CfnProject.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.EnvironmentVariableProperty instances
    • serializeEnvVariables

      @Stability(Stable) @NotNull public static List<CfnProject.EnvironmentVariableProperty> serializeEnvVariables(@NotNull Map<String,? extends BuildEnvironmentVariable> environmentVariables)
      Convert the environment variables map of string to BuildEnvironmentVariable, which is the customer-facing type, to a list of CfnProject.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.EnvironmentVariableProperty instances
    • 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

      @Stability(Stable) public void addSecondaryArtifact(@NotNull IArtifacts secondaryArtifact)
      Adds a secondary artifact to the Project.

      Parameters:
      secondaryArtifact - the artifact to add as a secondary artifact. This parameter is required.
      See Also:
    • addSecondarySource

      @Stability(Stable) public void addSecondarySource(@NotNull ISource secondarySource)
      Adds a secondary source to the Project.

      Parameters:
      secondarySource - the source to add as a secondary source. This parameter is required.
      See Also:
    • addToRolePolicy

      @Stability(Stable) public void addToRolePolicy(@NotNull PolicyStatement statement)
      Add a permission only if there's a policy attached.

      Specified by:
      addToRolePolicy in interface IProject
      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:
      bindAsNotificationRuleSource in interface INotificationRuleSource
      Parameters:
      _scope - This parameter is required.
    • bindToCodePipeline

      @Stability(Stable) public void bindToCodePipeline(@NotNull software.constructs.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

      @Stability(Stable) @Nullable public BatchBuildConfig enableBatchBuilds()
      Enable batch builds.

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

      Specified by:
      enableBatchBuilds in interface IProject
    • metric

      @Stability(Stable) @NotNull public Metric metric(@NotNull String metricName, @Nullable MetricOptions props)
      Specified by:
      metric in interface IProject
      Parameters:
      metricName - The name of the metric. This parameter is required.
      props - Customization properties.
      Returns:
      a CloudWatch metric associated with this build project.
    • metric

      @Stability(Stable) @NotNull public Metric metric(@NotNull String metricName)
      Specified by:
      metric in interface IProject
      Parameters:
      metricName - The name of the metric. This parameter is required.
      Returns:
      a CloudWatch metric associated with this build project.
    • metricBuilds

      @Stability(Stable) @NotNull public Metric metricBuilds(@Nullable MetricOptions props)
      Measures the number of builds triggered.

      Units: Count

      Valid CloudWatch statistics: Sum

      Default: sum over 5 minutes

      Specified by:
      metricBuilds in interface IProject
      Parameters:
      props -
    • metricBuilds

      @Stability(Stable) @NotNull public Metric metricBuilds()
      Measures the number of builds triggered.

      Units: Count

      Valid CloudWatch statistics: Sum

      Default: sum over 5 minutes

      Specified by:
      metricBuilds in interface IProject
    • metricDuration

      @Stability(Stable) @NotNull public Metric metricDuration(@Nullable MetricOptions props)
      Measures the duration of all builds over time.

      Units: Seconds

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

      Default: average over 5 minutes

      Specified by:
      metricDuration in interface IProject
      Parameters:
      props -
    • metricDuration

      @Stability(Stable) @NotNull public Metric 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:
      metricDuration in interface IProject
    • metricFailedBuilds

      @Stability(Stable) @NotNull public Metric metricFailedBuilds(@Nullable MetricOptions props)
      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:
      metricFailedBuilds in interface IProject
      Parameters:
      props -
    • metricFailedBuilds

      @Stability(Stable) @NotNull public Metric 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:
      metricFailedBuilds in interface IProject
    • metricSucceededBuilds

      @Stability(Stable) @NotNull public Metric metricSucceededBuilds(@Nullable MetricOptions props)
      Measures the number of successful builds.

      Units: Count

      Valid CloudWatch statistics: Sum

      Default: sum over 5 minutes

      Specified by:
      metricSucceededBuilds in interface IProject
      Parameters:
      props -
    • metricSucceededBuilds

      @Stability(Stable) @NotNull public Metric metricSucceededBuilds()
      Measures the number of successful builds.

      Units: Count

      Valid CloudWatch statistics: Sum

      Default: sum over 5 minutes

      Specified by:
      metricSucceededBuilds in interface IProject
    • 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 to onEvent API.

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

      Specified by:
      notifyOn in interface IProject
      Parameters:
      id - This parameter is required.
      target - This parameter is required.
      options - This parameter is required.
      Returns:
      CodeStar Notifications rule associated with this build project.
    • 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:
      notifyOnBuildFailed in interface IProject
      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:
      notifyOnBuildFailed in interface IProject
      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:
      notifyOnBuildSucceeded in interface IProject
      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:
      notifyOnBuildSucceeded in interface IProject
      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 StateChangeEvent class.

      Specified by:
      onBuildFailed in interface IProject
      Parameters:
      id - This parameter is required.
      options -
    • onBuildFailed

      @Stability(Stable) @NotNull public Rule onBuildFailed(@NotNull String id)
      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 StateChangeEvent class.

      Specified by:
      onBuildFailed in interface IProject
      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 StateChangeEvent class.

      Specified by:
      onBuildStarted in interface IProject
      Parameters:
      id - This parameter is required.
      options -
    • onBuildStarted

      @Stability(Stable) @NotNull public Rule onBuildStarted(@NotNull String id)
      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 StateChangeEvent class.

      Specified by:
      onBuildStarted in interface IProject
      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 StateChangeEvent class.

      Specified by:
      onBuildSucceeded in interface IProject
      Parameters:
      id - This parameter is required.
      options -
    • onBuildSucceeded

      @Stability(Stable) @NotNull public Rule onBuildSucceeded(@NotNull String id)
      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 StateChangeEvent class.

      Specified by:
      onBuildSucceeded in interface IProject
      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.

      Specified by:
      onEvent in interface IProject
      Parameters:
      id - This parameter is required.
      options -
      See Also:
    • onEvent

      @Stability(Stable) @NotNull public Rule onEvent(@NotNull String id)
      Defines a CloudWatch event rule triggered when something happens with this project.

      Specified by:
      onEvent in interface IProject
      Parameters:
      id - This parameter is required.
      See Also:
    • 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:
      onPhaseChange in interface IProject
      Parameters:
      id - This parameter is required.
      options -
      See Also:
    • onPhaseChange

      @Stability(Stable) @NotNull public Rule onPhaseChange(@NotNull String id)
      Defines a CloudWatch event rule that triggers upon phase change of this build project.

      Specified by:
      onPhaseChange in interface IProject
      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-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.

      Specified by:
      onStateChange in interface IProject
      Parameters:
      id - This parameter is required.
      options -
      See Also:
    • onStateChange

      @Stability(Stable) @NotNull public Rule onStateChange(@NotNull String id)
      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.

      Specified by:
      onStateChange in interface IProject
      Parameters:
      id - This parameter is required.
      See Also:
    • getConnections

      @Stability(Stable) @NotNull public Connections getConnections()
      Access the Connections object.

      Will fail if this Project does not have a VPC set.

      Specified by:
      getConnections in interface IConnectable
    • getGrantPrincipal

      @Stability(Stable) @NotNull public IPrincipal getGrantPrincipal()
      The principal to grant permissions to.
      Specified by:
      getGrantPrincipal in interface IGrantable
    • getProjectArn

      @Stability(Stable) @NotNull public String getProjectArn()
      The ARN of the project.
      Specified by:
      getProjectArn in interface IProject
    • getProjectName

      @Stability(Stable) @NotNull public String getProjectName()
      The name of the project.
      Specified by:
      getProjectName in interface IProject
    • getRole

      @Stability(Stable) @Nullable public IRole getRole()
      The IAM role for this project.
      Specified by:
      getRole in interface IProject