CodeBuildOptions Struct
Options for customizing a single CodeBuild project.
| Source | pipelines/lib/codepipeline/codepipeline.ts |
|---|---|
| Type last changed |
Example
declare const source: pipelines.IFileSetProducer; // the repository source
declare const synthCommands: string[]; // Commands to synthesize your app
declare const installCommands: string[]; // Commands to install your toolchain
const pipeline = new pipelines.CodePipeline(this, 'Pipeline', {
// Standard CodePipeline properties...
synth: new pipelines.ShellStep('Synth', {
input: source,
commands: synthCommands,
}),
// Configure CodeBuild to use a drop-in Docker replacement.
codeBuildDefaults: {
partialBuildSpec: codebuild.BuildSpec.fromObject({
phases: {
install: {
// Add the shell commands to install your drop-in Docker
// replacement to the CodeBuild enviromment.
commands: installCommands,
},
},
}),
buildEnvironment: {
environmentVariables: {
// Instruct the AWS CDK to use `drop-in-replacement` instead of
// `docker` when building / publishing docker images.
// e.g., `drop-in-replacement build . -f path/to/Dockerfile`
CDK_DOCKER: { value: 'drop-in-replacement' },
},
},
},
});
# source: pipelines.IFileSetProducer # the repository source
# synth_commands: List[str] # Commands to synthesize your app
# install_commands: List[str]
# Commands to install your toolchain
pipeline = pipelines.CodePipeline(self, "Pipeline",
# Standard CodePipeline properties...
synth=pipelines.ShellStep("Synth",
input=source,
commands=synth_commands
),
# Configure CodeBuild to use a drop-in Docker replacement.
code_build_defaults=pipelines.CodeBuildOptions(
partial_build_spec=codebuild.BuildSpec.from_object({
"phases": {
"install": {
# Add the shell commands to install your drop-in Docker
# replacement to the CodeBuild enviromment.
"commands": install_commands
}
}
}),
build_environment=codebuild.BuildEnvironment(
environment_variables={
# Instruct the AWS CDK to use `drop-in-replacement` instead of
# `docker` when building / publishing docker images.
# e.g., `drop-in-replacement build . -f path/to/Dockerfile`
"CDK_DOCKER": codebuild.BuildEnvironmentVariable(value="drop-in-replacement")
}
)
)
)
IFileSetProducer source; // the repository source
String[] synthCommands; // Commands to synthesize your app
String[] installCommands;
// Commands to install your toolchain
CodePipeline pipeline = CodePipeline.Builder.create(this, "Pipeline")
// Standard CodePipeline properties...
.synth(ShellStep.Builder.create("Synth")
.input(source)
.commands(synthCommands)
.build())
// Configure CodeBuild to use a drop-in Docker replacement.
.codeBuildDefaults(CodeBuildOptions.builder()
.partialBuildSpec(BuildSpec.fromObject(Map.of(
"phases", Map.of(
"install", Map.of(
// Add the shell commands to install your drop-in Docker
// replacement to the CodeBuild enviromment.
"commands", installCommands)))))
.buildEnvironment(BuildEnvironment.builder()
.environmentVariables(Map.of(
// Instruct the AWS CDK to use `drop-in-replacement` instead of
// `docker` when building / publishing docker images.
// e.g., `drop-in-replacement build . -f path/to/Dockerfile`
"CDK_DOCKER", BuildEnvironmentVariable.builder().value("drop-in-replacement").build()))
.build())
.build())
.build();
// Install: dotnet add package Amazon.CDK.Lib
IFileSetProducer source; // the repository source
string[] synthCommands; // Commands to synthesize your app
string[] installCommands;
// Commands to install your toolchain
var pipeline = new CodePipeline(this, "Pipeline", new CodePipelineProps {
// Standard CodePipeline properties...
Synth = new ShellStep("Synth", new ShellStepProps {
Input = source,
Commands = synthCommands
}),
// Configure CodeBuild to use a drop-in Docker replacement.
CodeBuildDefaults = new CodeBuildOptions {
PartialBuildSpec = BuildSpec.FromObject(new Dictionary<string, object> {
{ "phases", new Dictionary<string, IDictionary<string, string[]>> {
{ "install", new Struct {
// Add the shell commands to install your drop-in Docker
// replacement to the CodeBuild enviromment.
Commands = installCommands
} }
} }
}),
BuildEnvironment = new BuildEnvironment {
EnvironmentVariables = new Dictionary<string, BuildEnvironmentVariable> {
// Instruct the AWS CDK to use `drop-in-replacement` instead of
// `docker` when building / publishing docker images.
// e.g., `drop-in-replacement build . -f path/to/Dockerfile`
{ "CDK_DOCKER", new BuildEnvironmentVariable { Value = "drop-in-replacement" } }
}
}
}
});
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var source IFileSetProducer // the repository source
var synthCommands []*string // Commands to synthesize your app
var installCommands []*string
// Commands to install your toolchain
pipeline := pipelines.NewCodePipeline(this, jsii.String("Pipeline"), &CodePipelineProps{
// Standard CodePipeline properties...
Synth: pipelines.NewShellStep(jsii.String("Synth"), &ShellStepProps{
Input: source,
Commands: synthCommands,
}),
// Configure CodeBuild to use a drop-in Docker replacement.
CodeBuildDefaults: &CodeBuildOptions{
PartialBuildSpec: codebuild.BuildSpec_FromObject(map[string]interface{}{
"phases": map[string]map[string][]*string{
"install": map[string][]*string{
// Add the shell commands to install your drop-in Docker
// replacement to the CodeBuild enviromment.
"commands": installCommands,
},
},
}),
BuildEnvironment: &BuildEnvironment{
EnvironmentVariables: map[string]BuildEnvironmentVariable{
// Instruct the AWS CDK to use `drop-in-replacement` instead of
// `docker` when building / publishing docker images.
// e.g., `drop-in-replacement build . -f path/to/Dockerfile`
"CDK_DOCKER": &BuildEnvironmentVariable{
"value": jsii.String("drop-in-replacement"),
},
},
},
},
})
Properties
buildEnvironmentoptionalBuildEnvironmentbuild_environmentoptionalBuildEnvironmentbuildEnvironmentoptionalBuildEnvironmentBuildEnvironmentoptionalBuildEnvironmentBuildEnvironmentoptionalBuildEnvironment #Default: Non-privileged build, SMALL instance, LinuxBuildImage.STANDARD_7_0
Default: No cache
fileSystemLocationsoptionalIFileSystemLocation[]file_system_locationsoptionaltyping.List[IFileSystemLocation]fileSystemLocationsoptionalList<IFileSystemLocation>FileSystemLocationsoptionalIFileSystemLocation[]FileSystemLocationsoptional*[]IFileSystemLocation #Default: no file system locations
A ProjectFileSystemLocation object specifies the identifier, location, mountOptions, mountPoint, and type of a file system created using Amazon Elastic File System. Requires a vpc to be set and privileged to be set to true.
loggingoptionalLoggingOptionsloggingoptionalLoggingOptionsloggingoptionalLoggingOptionsLoggingoptionalLoggingOptionsLoggingoptionalLoggingOptions #Default: no log configuration is set
A CodeBuild project can create logs in Amazon CloudWatch Logs, an S3 bucket, or both.
partialBuildSpecoptionalBuildSpecpartial_build_specoptionalBuildSpecpartialBuildSpecoptionalBuildSpecPartialBuildSpecoptionalBuildSpecPartialBuildSpecoptionalBuildSpec #Default: No initial BuildSpec
The BuildSpec must be available inline--it cannot reference a file on disk.
rolePolicyoptionalPolicyStatement[]role_policyoptionaltyping.List[PolicyStatement]rolePolicyoptionalList<PolicyStatement>RolePolicyoptionalPolicyStatement[]RolePolicyoptional*[]PolicyStatement #Default: No policy statements added to CodeBuild Project Role
securityGroupsoptionalISecurityGroup[]security_groupsoptionaltyping.List[ISecurityGroup]securityGroupsoptionalList<ISecurityGroup>SecurityGroupsoptionalISecurityGroup[]SecurityGroupsoptional*[]ISecurityGroup #Default: Security group will be automatically created.
Only used if 'vpc' is supplied.
subnetSelectionoptionalSubnetSelectionsubnet_selectionoptionalSubnetSelectionsubnetSelectionoptionalSubnetSelectionSubnetSelectionoptionalSubnetSelectionSubnetSelectionoptionalSubnetSelection #Default: All private subnets.
Only used if 'vpc' is supplied.
timeoutoptionalDurationtimeoutoptionalDurationtimeoutoptionalDurationTimeoutoptionalDurationTimeoutoptionalDuration = Duration.hours(1) #For valid values, see the timeoutInMinutes field in the AWS CodeBuild User Guide.