Class CodeBuildActionProps
Construction properties of the CodeBuildAction CodeBuild build CodePipeline action
.
Inheritance
Namespace: Amazon.CDK.AWS.CodePipeline.Actions
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class CodeBuildActionProps : Object, ICodeBuildActionProps, ICommonAwsActionProps, ICommonActionProps
Syntax (vb)
Public Class CodeBuildActionProps
Inherits Object
Implements ICodeBuildActionProps, ICommonAwsActionProps, ICommonActionProps
Remarks
ExampleMetadata: infused
Examples
// Create a Cloudfront Web Distribution
using Amazon.CDK.AWS.CloudFront;
Distribution distribution;
// Create the build project that will invalidate the cache
var invalidateBuildProject = new PipelineProject(this, "InvalidateProject", new PipelineProjectProps {
BuildSpec = BuildSpec.FromObject(new Dictionary<string, object> {
{ "version", "0.2" },
{ "phases", new Dictionary<string, IDictionary<string, string[]>> {
{ "build", new Struct {
Commands = new [] { "aws cloudfront create-invalidation --distribution-id ${CLOUDFRONT_ID} --paths \"/*\"" }
} }
} }
}),
EnvironmentVariables = new Dictionary<string, BuildEnvironmentVariable> {
{ "CLOUDFRONT_ID", new BuildEnvironmentVariable { Value = distribution.DistributionId } }
}
});
// Add Cloudfront invalidation permissions to the project
var distributionArn = $"arn:aws:cloudfront::{this.account}:distribution/{distribution.distributionId}";
invalidateBuildProject.AddToRolePolicy(new PolicyStatement(new PolicyStatementProps {
Resources = new [] { distributionArn },
Actions = new [] { "cloudfront:CreateInvalidation" }
}));
// Create the pipeline (here only the S3 deploy and Invalidate cache build)
var deployBucket = new Bucket(this, "DeployBucket");
var deployInput = new Artifact();
new Pipeline(this, "Pipeline", new PipelineProps {
Stages = new [] { new StageProps {
StageName = "Deploy",
Actions = new [] {
new S3DeployAction(new S3DeployActionProps {
ActionName = "S3Deploy",
Bucket = deployBucket,
Input = deployInput,
RunOrder = 1
}),
new CodeBuildAction(new CodeBuildActionProps {
ActionName = "InvalidateCache",
Project = invalidateBuildProject,
Input = deployInput,
RunOrder = 2
}) }
} }
});
Synopsis
Constructors
CodeBuildActionProps() |
Properties
ActionName | The physical, human-readable name of the Action. |
CheckSecretsInPlainTextEnvVariables | Whether to check for the presence of any secrets in the environment variables of the default type, BuildEnvironmentVariableType.PLAINTEXT. Since using a secret for the value of that kind of variable would result in it being displayed in plain text in the AWS Console, the construct will throw an exception if it detects a secret was passed there. Pass this property as false if you want to skip this validation, and keep using a secret in a plain text environment variable. |
CombineBatchBuildArtifacts | Combine the build artifacts for a batch builds. |
EnvironmentVariables | The environment variables to pass to the CodeBuild project when this action executes. |
ExecuteBatchBuild | Trigger a batch build. |
ExtraInputs | The list of additional input Artifacts for this action. |
Input | The source to use as input for this action. |
Outputs | The list of output Artifacts for this action. |
Project | The action's Project. |
Role | The Role in which context's this Action will be executing in. |
RunOrder | The runOrder property for this Action. |
Type | The type of the action that determines its CodePipeline Category - Build, or Test. |
VariablesNamespace | The name of the namespace to use for variables emitted by this action. |
Constructors
CodeBuildActionProps()
public CodeBuildActionProps()
Properties
ActionName
The physical, human-readable name of the Action.
public string ActionName { get; set; }
Property Value
System.String
Remarks
Note that Action names must be unique within a single Stage.
CheckSecretsInPlainTextEnvVariables
Whether to check for the presence of any secrets in the environment variables of the default type, BuildEnvironmentVariableType.PLAINTEXT. Since using a secret for the value of that kind of variable would result in it being displayed in plain text in the AWS Console, the construct will throw an exception if it detects a secret was passed there. Pass this property as false if you want to skip this validation, and keep using a secret in a plain text environment variable.
public Nullable<bool> CheckSecretsInPlainTextEnvVariables { get; set; }
Property Value
System.Nullable<System.Boolean>
Remarks
Default: true
CombineBatchBuildArtifacts
Combine the build artifacts for a batch builds.
public Nullable<bool> CombineBatchBuildArtifacts { get; set; }
Property Value
System.Nullable<System.Boolean>
Remarks
Enabling this will combine the build artifacts into the same location for batch builds.
If executeBatchBuild
is not set to true
, this property is ignored.
Default: false
EnvironmentVariables
The environment variables to pass to the CodeBuild project when this action executes.
public IDictionary<string, IBuildEnvironmentVariable> EnvironmentVariables { get; set; }
Property Value
System.Collections.Generic.IDictionary<System.String, IBuildEnvironmentVariable>
Remarks
If a variable with the same name was set both on the project level, and here, this value will take precedence.
Default: - No additional environment variables are specified.
ExecuteBatchBuild
Trigger a batch build.
public Nullable<bool> ExecuteBatchBuild { get; set; }
Property Value
System.Nullable<System.Boolean>
Remarks
Enabling this will enable batch builds on the CodeBuild project.
Default: false
ExtraInputs
The list of additional input Artifacts for this action.
public Artifact_[] ExtraInputs { get; set; }
Property Value
Remarks
The directories the additional inputs will be available at are available
during the project's build in the CODEBUILD_SRC_DIR_input
property.
For more information,
see https://docs.aws.amazon.com/codebuild/latest/userguide/sample-multi-in-out.html .
Input
The source to use as input for this action.
public Artifact_ Input { get; set; }
Property Value
Outputs
The list of output Artifacts for this action.
public Artifact_[] Outputs { get; set; }
Property Value
Remarks
Note: if you specify more than one output Artifact here, you cannot use the primary 'artifacts' section of the buildspec; you have to use the 'secondary-artifacts' section instead. See https://docs.aws.amazon.com/codebuild/latest/userguide/sample-multi-in-out.html for details.
Default: the action will not have any outputs
Project
Role
The Role in which context's this Action will be executing in.
public IRole Role { get; set; }
Property Value
Remarks
The Pipeline's Role will assume this Role
(the required permissions for that will be granted automatically)
right before executing this Action.
This Action will be passed into your IAction.bind
method in the ActionBindOptions.role
property.
Default: a new Role will be generated
RunOrder
The runOrder property for this Action.
public Nullable<double> RunOrder { get; set; }
Property Value
System.Nullable<System.Double>
Remarks
RunOrder determines the relative order in which multiple Actions in the same Stage execute.
Default: 1
See: https://docs.aws.amazon.com/codepipeline/latest/userguide/reference-pipeline-structure.html
Type
The type of the action that determines its CodePipeline Category - Build, or Test.
public Nullable<CodeBuildActionType> Type { get; set; }
Property Value
System.Nullable<CodeBuildActionType>
Remarks
Default: CodeBuildActionType.BUILD
VariablesNamespace
The name of the namespace to use for variables emitted by this action.
public string VariablesNamespace { get; set; }
Property Value
System.String
Remarks
Default: - a name will be generated, based on the stage and action names, if any of the action's variables were referenced - otherwise, no namespace will be set