@Generated(value="jsii-pacmak/1.67.0 (build 2c027f5)", date="2022-09-19T20:26:42.927Z") @Stability(value=Stable) public class CodeBuildStep extends ShellStep
The BuildSpec must be available inline--it cannot reference a file
on disk. If your current build instructions are in a file like
buildspec.yml in your repository, extract them to a script
(say, build.sh) and invoke that script as part of the build:
CodeBuildStep.Builder.create("Synth")
.commands(List.of("./build.sh"))
.build();
Example:
CodePipeline.Builder.create(this, "Pipeline")
.synth(CodeBuildStep.Builder.create("Synth")
.input(CodePipelineSource.connection("my-org/my-app", "main", ConnectionSourceOptions.builder()
.connectionArn("arn:aws:codestar-connections:us-east-1:222222222222:connection/7d2469ff-514a-4e4f-9003-5ca4a43cdc41")
.build()))
.commands(List.of("...", "npm ci", "npm run build", "npx cdk synth", "..."))
.rolePolicyStatements(List.of(
PolicyStatement.Builder.create()
.actions(List.of("sts:AssumeRole"))
.resources(List.of("*"))
.conditions(Map.of(
"StringEquals", Map.of(
"iam:ResourceTag/aws-cdk:bootstrap-role", "lookup")))
.build()))
.build())
.build();
| Modifier and Type | Class and Description |
|---|---|
static class |
CodeBuildStep.Builder
A fluent builder for
CodeBuildStep. |
software.amazon.jsii.JsiiObject.InitializationModeIFileSetProducer.Jsii$Default| Modifier | Constructor and Description |
|---|---|
protected |
CodeBuildStep(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) |
protected |
CodeBuildStep(software.amazon.jsii.JsiiObjectRef objRef) |
|
CodeBuildStep(String id,
CodeBuildStepProps props) |
| Modifier and Type | Method and Description |
|---|---|
String |
exportedVariable(String variableName)
Reference a CodePipeline variable defined by the CodeBuildStep.
|
IRole |
getActionRole()
Custom execution role to be used for the Code Build Action.
|
BuildEnvironment |
getBuildEnvironment()
Build environment.
|
Cache |
getCache()
Caching strategy to use.
|
IPrincipal |
getGrantPrincipal()
The CodeBuild Project's principal.
|
BuildSpec |
getPartialBuildSpec()
Additional configuration that can only be configured via BuildSpec.
|
IProject |
getProject()
CodeBuild Project generated for the pipeline.
|
String |
getProjectName()
Name for the generated CodeBuild project.
|
IRole |
getRole()
Custom execution role to be used for the CodeBuild project.
|
List<PolicyStatement> |
getRolePolicyStatements()
Policy statements to add to role used during the synth.
|
List<ISecurityGroup> |
getSecurityGroups()
Which security group to associate with the script's project network interfaces.
|
SubnetSelection |
getSubnetSelection()
Which subnets to use.
|
Duration |
getTimeout()
The number of minutes after which AWS CodeBuild stops the build if it's not complete.
|
IVpc |
getVpc()
The VPC where to execute the SimpleSynth.
|
addOutputDirectory, getCommands, getEnv, getEnvFromCfnOutputs, getInputs, getInstallCommands, getOutputs, primaryOutputDirectoryaddDependencyFileSet, addStepDependency, configurePrimaryOutput, discoverReferencedOutputs, getDependencies, getDependencyFileSets, getId, getIsSource, getPrimaryOutput, sequence, toStringjsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSetprotected CodeBuildStep(software.amazon.jsii.JsiiObjectRef objRef)
protected CodeBuildStep(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
@Stability(value=Stable)
public CodeBuildStep(@NotNull
String id,
@NotNull
CodeBuildStepProps props)
id - This parameter is required.props - This parameter is required.@Stability(value=Stable) @NotNull public String exportedVariable(@NotNull String variableName)
The variable must be set in the shell of the CodeBuild step when
it finishes its post_build phase.
Example:
// Access the output of one CodeBuildStep in another CodeBuildStep
CodePipeline pipeline;
CodeBuildStep step1 = CodeBuildStep.Builder.create("Step1")
.commands(List.of("export MY_VAR=hello"))
.build();
CodeBuildStep step2 = CodeBuildStep.Builder.create("Step2")
.env(Map.of(
"IMPORTED_VAR", step1.exportedVariable("MY_VAR")))
.commands(List.of("echo $IMPORTED_VAR"))
.build();
variableName - the name of the variable for reference. This parameter is required.@Stability(value=Stable) @NotNull public IPrincipal getGrantPrincipal()
@Stability(value=Stable) @NotNull public IProject getProject()
Will only be available after the pipeline has been built.
@Stability(value=Stable) @Nullable public IRole getActionRole()
Default: - A role is automatically created
@Stability(value=Stable) @Nullable public BuildEnvironment getBuildEnvironment()
Default: - No value specified at construction time, use defaults
@Stability(value=Stable) @Nullable public Cache getCache()
Default: - No cache
@Stability(value=Stable) @Nullable public BuildSpec getPartialBuildSpec()
Contains exported variables
Default: - Contains the exported variables
@Stability(value=Stable) @Nullable public String getProjectName()
Default: - No value specified at construction time, use defaults
@Stability(value=Stable) @Nullable public IRole getRole()
Default: - No value specified at construction time, use defaults
@Stability(value=Stable) @Nullable public List<PolicyStatement> getRolePolicyStatements()
Default: - No value specified at construction time, use defaults
@Stability(value=Stable) @Nullable public List<ISecurityGroup> getSecurityGroups()
Default: - No value specified at construction time, use defaults
@Stability(value=Stable) @Nullable public SubnetSelection getSubnetSelection()
Default: - No value specified at construction time, use defaults
@Stability(value=Stable) @Nullable public Duration getTimeout()
For valid values, see the timeoutInMinutes field in the AWS CodeBuild User Guide.
Default: Duration.hours(1)
@Stability(value=Stable) @Nullable public IVpc getVpc()
Default: - No value specified at construction time, use defaults
Copyright © 2022. All rights reserved.