Show / Hide Table of Contents

Class Project

A representation of a CodeBuild Project.

Inheritance
System.Object
Construct
Resource
Project
PipelineProject
Implements
IProject
IResource
IConstruct
Constructs.IConstruct
IDependable
IGrantable
IConnectable
Inherited Members
Resource.IsResource(IConstruct)
Resource.ApplyRemovalPolicy(RemovalPolicy)
Resource.GeneratePhysicalName()
Resource.GetResourceArnAttribute(String, IArnComponents)
Resource.GetResourceNameAttribute(String)
Resource.Env
Resource.PhysicalName
Resource.Stack
Construct.IsConstruct(Object)
Construct.OnPrepare()
Construct.OnSynthesize(ISynthesisSession)
Construct.OnValidate()
Construct.Prepare()
Construct.Synthesize(ISynthesisSession)
Construct.Node
Namespace: Amazon.CDK.AWS.CodeBuild
Assembly: Amazon.CDK.AWS.CodeBuild.dll
Syntax (csharp)
public class Project : Resource, IProject, IResource, IConstruct, IConstruct, IDependable, IGrantable, IConnectable
Syntax (vb)
Public Class Project
    Inherits Resource
    Implements IProject, IResource, IConstruct, IConstruct, IDependable, IGrantable, IConnectable

Synopsis

Constructors

Project(ByRefValue)

Used by jsii to construct an instance of this class from a Javascript-owned object reference

Project(DeputyBase.DeputyProps)

Used by jsii to construct an instance of this class from DeputyProps

Project(Construct, String, IProjectProps)

Properties

Connections

Access the Connections object.

GrantPrincipal

The principal to grant permissions to.

ProjectArn

The ARN of the project.

ProjectName

The name of the project.

Role

The IAM role for this project.

Methods

AddFileSystemLocation(IFileSystemLocation)

Adds a fileSystemLocation to the Project.

AddSecondaryArtifact(IArtifacts)

Adds a secondary artifact to the Project.

AddSecondarySource(ISource)

Adds a secondary source to the Project.

AddToRolePolicy(PolicyStatement)

Add a permission only if there's a policy attached.

BindToCodePipeline(Construct, IBindToCodePipelineOptions)

A callback invoked when the given project is added to a CodePipeline.

EnableBatchBuilds()

Enable batch builds.

FromProjectArn(Construct, String, String)
FromProjectName(Construct, String, String)

Import a Project defined either outside the CDK, or in a different CDK Stack (and exported using the {@link export} method).

Metric(String, IMetricOptions)
MetricBuilds(IMetricOptions)

Measures the number of builds triggered.

MetricDuration(IMetricOptions)

Measures the duration of all builds over time.

MetricFailedBuilds(IMetricOptions)

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

MetricSucceededBuilds(IMetricOptions)

Measures the number of successful builds.

OnBuildFailed(String, IOnEventOptions)

Defines an event rule which triggers when a build fails.

OnBuildStarted(String, IOnEventOptions)

Defines an event rule which triggers when a build starts.

OnBuildSucceeded(String, IOnEventOptions)

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

OnEvent(String, IOnEventOptions)

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

OnPhaseChange(String, IOnEventOptions)

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

OnStateChange(String, IOnEventOptions)

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

SerializeEnvVariables(IDictionary<String, IBuildEnvironmentVariable>, Nullable<Boolean>, IGrantable)

Convert the environment variables map of string to {@link BuildEnvironmentVariable}, which is the customer-facing type, to a list of {@link CfnProject.EnvironmentVariableProperty}, which is the representation of environment variables in CloudFormation.

Validate()

Validate the current construct.

Constructors

Project(ByRefValue)

Used by jsii to construct an instance of this class from a Javascript-owned object reference

protected Project(ByRefValue reference)
Parameters
reference Amazon.JSII.Runtime.Deputy.ByRefValue

The Javascript-owned object reference

Project(DeputyBase.DeputyProps)

Used by jsii to construct an instance of this class from DeputyProps

protected Project(DeputyBase.DeputyProps props)
Parameters
props Amazon.JSII.Runtime.Deputy.DeputyBase.DeputyProps

The deputy props

Project(Construct, String, IProjectProps)

public Project(Construct scope, string id, IProjectProps props)
Parameters
scope Constructs.Construct
id System.String
props IProjectProps

Properties

Connections

Access the Connections object.

public virtual Connections_ Connections { get; }
Property Value

Connections_

Remarks

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

GrantPrincipal

The principal to grant permissions to.

public virtual IPrincipal GrantPrincipal { get; }
Property Value

IPrincipal

ProjectArn

The ARN of the project.

public virtual string ProjectArn { get; }
Property Value

System.String

ProjectName

The name of the project.

public virtual string ProjectName { get; }
Property Value

System.String

Role

The IAM role for this project.

public virtual IRole Role { get; }
Property Value

IRole

Methods

AddFileSystemLocation(IFileSystemLocation)

Adds a fileSystemLocation to the Project.

public virtual void AddFileSystemLocation(IFileSystemLocation fileSystemLocation)
Parameters
fileSystemLocation IFileSystemLocation

the fileSystemLocation to add.

AddSecondaryArtifact(IArtifacts)

Adds a secondary artifact to the Project.

public virtual void AddSecondaryArtifact(IArtifacts secondaryArtifact)
Parameters
secondaryArtifact IArtifacts

the artifact to add as a secondary artifact.

Remarks

See: https://docs.aws.amazon.com/codebuild/latest/userguide/sample-multi-in-out.html

AddSecondarySource(ISource)

Adds a secondary source to the Project.

public virtual void AddSecondarySource(ISource secondarySource)
Parameters
secondarySource ISource

the source to add as a secondary source.

Remarks

See: https://docs.aws.amazon.com/codebuild/latest/userguide/sample-multi-in-out.html

AddToRolePolicy(PolicyStatement)

Add a permission only if there's a policy attached.

public virtual void AddToRolePolicy(PolicyStatement statement)
Parameters
statement PolicyStatement

The permissions statement to add.

BindToCodePipeline(Construct, IBindToCodePipelineOptions)

A callback invoked when the given project is added to a CodePipeline.

public virtual void BindToCodePipeline(Construct scope, IBindToCodePipelineOptions options)
Parameters
scope Construct

the construct the binding is taking place in.

options IBindToCodePipelineOptions

additional options for the binding.

EnableBatchBuilds()

Enable batch builds.

public virtual IBatchBuildConfig EnableBatchBuilds()
Returns

IBatchBuildConfig

Remarks

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

FromProjectArn(Construct, String, String)

public static IProject FromProjectArn(Construct scope, string id, string projectArn)
Parameters
scope Constructs.Construct
id System.String
projectArn System.String
Returns

IProject

FromProjectName(Construct, String, String)

Import a Project defined either outside the CDK, or in a different CDK Stack (and exported using the {@link export} method).

public static IProject FromProjectName(Construct scope, string id, string projectName)
Parameters
scope Constructs.Construct

the parent Construct for this Construct.

id System.String

the logical name of this Construct.

projectName System.String

the name of the project to import.

Returns

IProject

a reference to the existing Project

Remarks

Note: if you're importing a CodeBuild Project for use in a CodePipeline, make sure the existing Project has permissions to access the S3 Bucket of that Pipeline - otherwise, builds in that Pipeline will always fail.

Metric(String, IMetricOptions)

public virtual Metric Metric(string metricName, IMetricOptions props = null)
Parameters
metricName System.String

The name of the metric.

props IMetricOptions

Customization properties.

Returns

Metric

a CloudWatch metric associated with this build project.

MetricBuilds(IMetricOptions)

Measures the number of builds triggered.

public virtual Metric MetricBuilds(IMetricOptions props = null)
Parameters
props IMetricOptions
Returns

Metric

Remarks

Units: Count

Valid CloudWatch statistics: Sum

Default: sum over 5 minutes

MetricDuration(IMetricOptions)

Measures the duration of all builds over time.

public virtual Metric MetricDuration(IMetricOptions props = null)
Parameters
props IMetricOptions
Returns

Metric

Remarks

Units: Seconds

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

Default: average over 5 minutes

MetricFailedBuilds(IMetricOptions)

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

public virtual Metric MetricFailedBuilds(IMetricOptions props = null)
Parameters
props IMetricOptions
Returns

Metric

Remarks

Units: Count

Valid CloudWatch statistics: Sum

Default: sum over 5 minutes

MetricSucceededBuilds(IMetricOptions)

Measures the number of successful builds.

public virtual Metric MetricSucceededBuilds(IMetricOptions props = null)
Parameters
props IMetricOptions
Returns

Metric

Remarks

Units: Count

Valid CloudWatch statistics: Sum

Default: sum over 5 minutes

OnBuildFailed(String, IOnEventOptions)

Defines an event rule which triggers when a build fails.

public virtual Rule OnBuildFailed(string id, IOnEventOptions options = null)
Parameters
id System.String
options IOnEventOptions
Returns

Rule

Remarks

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

OnBuildStarted(String, IOnEventOptions)

Defines an event rule which triggers when a build starts.

public virtual Rule OnBuildStarted(string id, IOnEventOptions options = null)
Parameters
id System.String
options IOnEventOptions
Returns

Rule

Remarks

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

OnBuildSucceeded(String, IOnEventOptions)

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

public virtual Rule OnBuildSucceeded(string id, IOnEventOptions options = null)
Parameters
id System.String
options IOnEventOptions
Returns

Rule

Remarks

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

OnEvent(String, IOnEventOptions)

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

public virtual Rule OnEvent(string id, IOnEventOptions options = null)
Parameters
id System.String
options IOnEventOptions
Returns

Rule

Remarks

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

OnPhaseChange(String, IOnEventOptions)

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

public virtual Rule OnPhaseChange(string id, IOnEventOptions options = null)
Parameters
id System.String
options IOnEventOptions
Returns

Rule

Remarks

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

OnStateChange(String, IOnEventOptions)

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

public virtual Rule OnStateChange(string id, IOnEventOptions options = null)
Parameters
id System.String
options IOnEventOptions
Returns

Rule

Remarks

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: https://docs.aws.amazon.com/codebuild/latest/userguide/sample-build-notifications.html

SerializeEnvVariables(IDictionary<String, IBuildEnvironmentVariable>, Nullable<Boolean>, IGrantable)

Convert the environment variables map of string to {@link BuildEnvironmentVariable}, which is the customer-facing type, to a list of {@link CfnProject.EnvironmentVariableProperty}, which is the representation of environment variables in CloudFormation.

public static CfnProject.IEnvironmentVariableProperty[] SerializeEnvVariables(IDictionary<string, IBuildEnvironmentVariable> environmentVariables, Nullable<bool> validateNoPlainTextSecrets = null, IGrantable principal = null)
Parameters
environmentVariables System.Collections.Generic.IDictionary<System.String, IBuildEnvironmentVariable>

the map of string to environment variables.

validateNoPlainTextSecrets System.Nullable<System.Boolean>

whether to throw an exception if any of the plain text environment variables contain secrets, defaults to 'false'.

principal IGrantable

the map of string to environment variables.

Returns

CfnProject.IEnvironmentVariableProperty[]

an array of {@link CfnProject.EnvironmentVariableProperty} instances

Validate()

Validate the current construct.

protected override string[] Validate()
Returns

System.String[]

Overrides
Construct.Validate()
Remarks

This method can be implemented by derived constructs in order to perform validation logic. It is called on all constructs before synthesis.

Override: true

Implements

IProject
IResource
IConstruct
Constructs.IConstruct
IDependable
IGrantable
IConnectable
Back to top Generated by DocFX