Class: AWSCDK::Pipelines::CodeBuildStep

Inherits:
ShellStep
  • Object
show all
Defined in:
pipelines/code_build_step.rb

Overview

Run a script as a CodeBuild Project.

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:

AWSCDK::Pipelines::CodeBuildStep.new("Synth", {
    commands: ["./build.sh"],
})

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, props) ⇒ CodeBuildStep

Returns a new instance of CodeBuildStep.

Parameters:



21
22
23
24
25
26
# File 'pipelines/code_build_step.rb', line 21

def initialize(id, props)
  props = props.is_a?(Hash) ? ::AWSCDK::Pipelines::CodeBuildStepProps.new(**props.transform_keys(&:to_sym)) : props
  Jsii::Type.check_type(id, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "id")
  Jsii::Type.check_type(props, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5waXBlbGluZXMuQ29kZUJ1aWxkU3RlcFByb3BzIn0=")), "props")
  Jsii::Object.instance_method(:initialize).bind(self).call(id, props)
end

Class Method Details

.jsii_overridable_methodsObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'pipelines/code_build_step.rb', line 28

def self.jsii_overridable_methods
  {
    :consumed_stack_outputs => { kind: :property, name: "consumedStackOutputs", is_optional: false },
    :dependencies => { kind: :property, name: "dependencies", is_optional: false },
    :dependency_file_sets => { kind: :property, name: "dependencyFileSets", is_optional: false },
    :id => { kind: :property, name: "id", is_optional: false },
    :is_source => { kind: :property, name: "isSource", is_optional: false },
    :primary_output => { kind: :property, name: "primaryOutput", is_optional: true },
    :commands => { kind: :property, name: "commands", is_optional: false },
    :env => { kind: :property, name: "env", is_optional: false },
    :env_from_cfn_outputs => { kind: :property, name: "envFromCfnOutputs", is_optional: false },
    :inputs => { kind: :property, name: "inputs", is_optional: false },
    :install_commands => { kind: :property, name: "installCommands", is_optional: false },
    :outputs => { kind: :property, name: "outputs", is_optional: false },
    :grant_principal => { kind: :property, name: "grantPrincipal", is_optional: false },
    :project => { kind: :property, name: "project", is_optional: false },
    :action_role => { kind: :property, name: "actionRole", is_optional: true },
    :build_environment => { kind: :property, name: "buildEnvironment", is_optional: true },
    :cache => { kind: :property, name: "cache", is_optional: true },
    :file_system_locations => { kind: :property, name: "fileSystemLocations", is_optional: true },
    :logging => { kind: :property, name: "logging", is_optional: true },
    :partial_build_spec => { kind: :property, name: "partialBuildSpec", is_optional: true },
    :project_name => { kind: :property, name: "projectName", is_optional: true },
    :role => { kind: :property, name: "role", is_optional: true },
    :role_policy_statements => { kind: :property, name: "rolePolicyStatements", is_optional: true },
    :security_groups => { kind: :property, name: "securityGroups", is_optional: true },
    :subnet_selection => { kind: :property, name: "subnetSelection", is_optional: true },
    :timeout => { kind: :property, name: "timeout", is_optional: true },
    :vpc => { kind: :property, name: "vpc", is_optional: true },
    :add_dependency_file_set => { kind: :method, name: "addDependencyFileSet", is_optional: false },
    :add_step_dependency => { kind: :method, name: "addStepDependency", is_optional: false },
    :configure_primary_output => { kind: :method, name: "configurePrimaryOutput", is_optional: false },
    :discover_referenced_outputs => { kind: :method, name: "discoverReferencedOutputs", is_optional: false },
    :to_string => { kind: :method, name: "toString", is_optional: false },
    :add_output_directory => { kind: :method, name: "addOutputDirectory", is_optional: false },
    :primary_output_directory => { kind: :method, name: "primaryOutputDirectory", is_optional: false },
    :exported_variable => { kind: :method, name: "exportedVariable", is_optional: false },
  }
end

Instance Method Details

#action_roleAWSCDK::IAM::IRole?

Note:

Default: - A role is automatically created

Custom execution role to be used for the Code Build Action.

Returns:



189
190
191
# File 'pipelines/code_build_step.rb', line 189

def action_role()
  jsii_get_property("actionRole")
end

#add_dependency_file_set(fs) ⇒ void

This method returns an undefined value.

Add an additional FileSet to the set of file sets required by this step.

This will lead to a dependency on the producer of that file set.

Parameters:



305
306
307
308
# File 'pipelines/code_build_step.rb', line 305

def add_dependency_file_set(fs)
  Jsii::Type.check_type(fs, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5waXBlbGluZXMuRmlsZVNldCJ9")), "fs")
  jsii_call_method("addDependencyFileSet", [fs])
end

#add_output_directory(directory) ⇒ AWSCDK::Pipelines::FileSet

Add an additional output FileSet based on a directory.

After running the script, the contents of the given directory will be exported as a FileSet. Use the FileSet as the input to another step.

Multiple calls with the exact same directory name string (not normalized) will return the same FileSet.

Parameters:

  • directory (String)

Returns:



360
361
362
363
# File 'pipelines/code_build_step.rb', line 360

def add_output_directory(directory)
  Jsii::Type.check_type(directory, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "directory")
  jsii_call_method("addOutputDirectory", [directory])
end

#add_step_dependency(step) ⇒ void

This method returns an undefined value.

Add a dependency on another step.

Parameters:



314
315
316
317
# File 'pipelines/code_build_step.rb', line 314

def add_step_dependency(step)
  Jsii::Type.check_type(step, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5waXBlbGluZXMuU3RlcCJ9")), "step")
  jsii_call_method("addStepDependency", [step])
end

#build_environmentAWSCDK::CodeBuild::BuildEnvironment?

Note:

Default: - No value specified at construction time, use defaults

Build environment.



197
198
199
# File 'pipelines/code_build_step.rb', line 197

def build_environment()
  jsii_get_property("buildEnvironment")
end

#cacheAWSCDK::CodeBuild::Cache?

Note:

Default: - No cache

Caching strategy to use.

Returns:



205
206
207
# File 'pipelines/code_build_step.rb', line 205

def cache()
  jsii_get_property("cache")
end

#commandsArray<String>

Commands to run.

Returns:

  • (Array<String>)


118
119
120
# File 'pipelines/code_build_step.rb', line 118

def commands()
  jsii_get_property("commands")
end

#configure_primary_output(fs) ⇒ void

This method returns an undefined value.

Configure the given FileSet as the primary output of this step.

Parameters:



323
324
325
326
# File 'pipelines/code_build_step.rb', line 323

def configure_primary_output(fs)
  Jsii::Type.check_type(fs, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5waXBlbGluZXMuRmlsZVNldCJ9")), "fs")
  jsii_call_method("configurePrimaryOutput", [fs])
end

#consumed_stack_outputsArray<AWSCDK::Pipelines::StackOutputReference>

StackOutputReferences this step consumes.



71
72
73
# File 'pipelines/code_build_step.rb', line 71

def consumed_stack_outputs()
  jsii_get_property("consumedStackOutputs")
end

#dependenciesArray<AWSCDK::Pipelines::Step>

Return the steps this step depends on, based on the FileSets it requires.

Returns:



78
79
80
# File 'pipelines/code_build_step.rb', line 78

def dependencies()
  jsii_get_property("dependencies")
end

#dependency_file_setsArray<AWSCDK::Pipelines::FileSet>

The list of FileSets consumed by this Step.

Returns:



85
86
87
# File 'pipelines/code_build_step.rb', line 85

def dependency_file_sets()
  jsii_get_property("dependencyFileSets")
end

#discover_referenced_outputs(structure) ⇒ void

This method returns an undefined value.

Crawl the given structure for references to StepOutputs and add dependencies on all steps found.

Should be called in the constructor of subclasses based on what the user passes in as construction properties. The format of the structure passed in here does not have to correspond exactly to what gets rendered into the engine, it just needs to contain the same data.

Parameters:

  • structure (Object)


337
338
339
340
# File 'pipelines/code_build_step.rb', line 337

def discover_referenced_outputs(structure)
  Jsii::Type.check_type(structure, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJhbnkifQ==")), "structure")
  jsii_call_method("discoverReferencedOutputs", [structure])
end

#envHash{String => String}

Note:

Default: - No environment variables

Environment variables to set.

Returns:

  • (Hash{String => String})


126
127
128
# File 'pipelines/code_build_step.rb', line 126

def env()
  jsii_get_property("env")
end

#env_from_cfn_outputsHash{String => AWSCDK::Pipelines::StackOutputReference}

Note:

Default: - No environment variables created from stack outputs

Set environment variables based on Stack Outputs.

Returns:



134
135
136
# File 'pipelines/code_build_step.rb', line 134

def env_from_cfn_outputs()
  jsii_get_property("envFromCfnOutputs")
end

#exported_variable(variable_name) ⇒ String

Reference a CodePipeline variable defined by the CodeBuildStep.

The variable must be set in the shell of the CodeBuild step when it finishes its post_build phase.

Examples:

# Access the output of one CodeBuildStep in another CodeBuildStep
pipeline = nil # AWSCDK::Pipelines::CodePipeline

step1 = AWSCDK::Pipelines::CodeBuildStep.new("Step1", {
    commands: ["export MY_VAR=hello"],
})

step2 = AWSCDK::Pipelines::CodeBuildStep.new("Step2", {
    env: {
        IMPORTED_VAR: step1.exported_variable("MY_VAR"),
    },
    commands: ["echo $IMPORTED_VAR"],
})

Parameters:

  • variable_name (String)

    the name of the variable for reference.

Returns:

  • (String)


401
402
403
404
# File 'pipelines/code_build_step.rb', line 401

def exported_variable(variable_name)
  Jsii::Type.check_type(variable_name, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "variableName")
  jsii_call_method("exportedVariable", [variable_name])
end

#file_system_locationsArray<AWSCDK::CodeBuild::IFileSystemLocation>?

Note:

Default: - no file system locations

ProjectFileSystemLocation objects for CodeBuild build projects.

A ProjectFileSystemLocation object specifies the identifier, location, mountOptions, mountPoint, and type of a file system created using Amazon Elastic File System.



216
217
218
# File 'pipelines/code_build_step.rb', line 216

def file_system_locations()
  jsii_get_property("fileSystemLocations")
end

#grant_principalAWSCDK::IAM::IPrincipal

The CodeBuild Project's principal.



172
173
174
# File 'pipelines/code_build_step.rb', line 172

def grant_principal()
  jsii_get_property("grantPrincipal")
end

#idString

Identifier for this step.

Returns:

  • (String)


92
93
94
# File 'pipelines/code_build_step.rb', line 92

def id()
  jsii_get_property("id")
end

#inputsArray<AWSCDK::Pipelines::FileSetLocation>

Input FileSets.

A list of (FileSet, directory) pairs, which are a copy of the input properties. This list should not be modified directly.



144
145
146
# File 'pipelines/code_build_step.rb', line 144

def inputs()
  jsii_get_property("inputs")
end

#install_commandsArray<String>

Note:

Default: - No installation commands

Installation commands to run before the regular commands.

For deployment engines that support it, install commands will be classified differently in the job history from the regular commands.

Returns:

  • (Array<String>)


155
156
157
# File 'pipelines/code_build_step.rb', line 155

def install_commands()
  jsii_get_property("installCommands")
end

#is_sourceBoolean

Whether or not this is a Source step.

What it means to be a Source step depends on the engine.

Returns:

  • (Boolean)


101
102
103
# File 'pipelines/code_build_step.rb', line 101

def is_source()
  jsii_get_property("isSource")
end

#loggingAWSCDK::CodeBuild::LoggingOptions?

Note:

Default: - no log configuration is set

Information about logs for CodeBuild projects.

A CodeBuilde project can create logs in Amazon CloudWatch Logs, an S3 bucket, or both.



226
227
228
# File 'pipelines/code_build_step.rb', line 226

def logging()
  jsii_get_property("logging")
end

#outputsArray<AWSCDK::Pipelines::FileSetLocation>

Output FileSets.

A list of (FileSet, directory) pairs, which are a copy of the input properties. This list should not be modified directly.



165
166
167
# File 'pipelines/code_build_step.rb', line 165

def outputs()
  jsii_get_property("outputs")
end

#partial_build_specAWSCDK::CodeBuild::BuildSpec?

Note:

Default: - Contains the exported variables

Additional configuration that can only be configured via BuildSpec.

Contains exported variables



236
237
238
# File 'pipelines/code_build_step.rb', line 236

def partial_build_spec()
  jsii_get_property("partialBuildSpec")
end

#primary_outputAWSCDK::Pipelines::FileSet?

The primary FileSet produced by this Step.

Not all steps produce an output FileSet--if they do you can substitute the Step object for the FileSet object.

Returns:



111
112
113
# File 'pipelines/code_build_step.rb', line 111

def primary_output()
  jsii_get_property("primaryOutput")
end

#primary_output_directory(directory) ⇒ AWSCDK::Pipelines::FileSet

Configure the given output directory as primary output.

If no primary output has been configured yet, this directory will become the primary output of this ShellStep, otherwise this method will throw if the given directory is different than the currently configured primary output directory.

Parameters:

  • directory (String)

Returns:



374
375
376
377
# File 'pipelines/code_build_step.rb', line 374

def primary_output_directory(directory)
  Jsii::Type.check_type(directory, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "directory")
  jsii_call_method("primaryOutputDirectory", [directory])
end

#projectAWSCDK::CodeBuild::IProject

CodeBuild Project generated for the pipeline.

Will only be available after the pipeline has been built.



181
182
183
# File 'pipelines/code_build_step.rb', line 181

def project()
  jsii_get_property("project")
end

#project_nameString?

Note:

Default: - No value specified at construction time, use defaults

Name for the generated CodeBuild project.

Returns:

  • (String, nil)


244
245
246
# File 'pipelines/code_build_step.rb', line 244

def project_name()
  jsii_get_property("projectName")
end

#roleAWSCDK::IAM::IRole?

Note:

Default: - No value specified at construction time, use defaults

Custom execution role to be used for the CodeBuild project.

Returns:



252
253
254
# File 'pipelines/code_build_step.rb', line 252

def role()
  jsii_get_property("role")
end

#role_policy_statementsArray<AWSCDK::IAM::PolicyStatement>?

Note:

Default: - No value specified at construction time, use defaults

Policy statements to add to role used during the synth.

Returns:



260
261
262
# File 'pipelines/code_build_step.rb', line 260

def role_policy_statements()
  jsii_get_property("rolePolicyStatements")
end

#security_groupsArray<AWSCDK::EC2::ISecurityGroup>?

Note:

Default: - No value specified at construction time, use defaults

Which security group to associate with the script's project network interfaces.

Returns:



268
269
270
# File 'pipelines/code_build_step.rb', line 268

def security_groups()
  jsii_get_property("securityGroups")
end

#subnet_selectionAWSCDK::EC2::SubnetSelection?

Note:

Default: - No value specified at construction time, use defaults

Which subnets to use.



276
277
278
# File 'pipelines/code_build_step.rb', line 276

def subnet_selection()
  jsii_get_property("subnetSelection")
end

#timeoutAWSCDK::Duration?

Note:

Default: Duration.hours(1)

The number of minutes after which AWS CodeBuild stops the build if it's not complete.

For valid values, see the timeoutInMinutes field in the AWS CodeBuild User Guide.

Returns:



287
288
289
# File 'pipelines/code_build_step.rb', line 287

def timeout()
  jsii_get_property("timeout")
end

#to_stringString

Return a string representation of this Step.

Returns:

  • (String)


345
346
347
# File 'pipelines/code_build_step.rb', line 345

def to_string()
  jsii_call_method("toString", [])
end

#vpcAWSCDK::EC2::IVPC?

Note:

Default: - No value specified at construction time, use defaults

The VPC where to execute the SimpleSynth.

Returns:



295
296
297
# File 'pipelines/code_build_step.rb', line 295

def vpc()
  jsii_get_property("vpc")
end