ShellStep

class aws_cdk.pipelines.ShellStep(id, *, commands, additional_inputs=None, env=None, env_from_cfn_outputs=None, input=None, install_commands=None, primary_output_directory=None)

Bases: aws_cdk.pipelines.Step

Run shell script commands in the pipeline.

This is a generic step designed to be deployment engine agnostic.

ExampleMetadata

infused

Example:

# code_pipeline: codepipeline.Pipeline


pipeline = pipelines.CodePipeline(self, "Pipeline",
    synth=pipelines.ShellStep("Synth",
        input=pipelines.CodePipelineSource.connection("my-org/my-app", "main",
            connection_arn="arn:aws:codestar-connections:us-east-1:222222222222:connection/7d2469ff-514a-4e4f-9003-5ca4a43cdc41"
        ),
        commands=["npm ci", "npm run build", "npx cdk synth"]
    ),
    code_pipeline=code_pipeline
)
Parameters
  • id (str) –

  • commands (Sequence[str]) – Commands to run.

  • additional_inputs (Optional[Mapping[str, IFileSetProducer]]) – Additional FileSets to put in other directories. Specifies a mapping from directory name to FileSets. During the script execution, the FileSets will be available in the directories indicated. The directory names may be relative. For example, you can put the main input and an additional input side-by-side with the following configuration:: const script = new pipelines.ShellStep(‘MainScript’, { commands: [‘npm ci’,’npm run build’,’npx cdk synth’], input: pipelines.CodePipelineSource.gitHub(‘org/source1’, ‘main’), additionalInputs: { ‘../siblingdir’: pipelines.CodePipelineSource.gitHub(‘org/source2’, ‘main’), } }); Default: - No additional inputs

  • env (Optional[Mapping[str, str]]) – Environment variables to set. Default: - No environment variables

  • env_from_cfn_outputs (Optional[Mapping[str, CfnOutput]]) – Set environment variables based on Stack Outputs. ``ShellStep``s following stack or stage deployments may access the ``CfnOutput``s of those stacks to get access to –for example–automatically generated resource names or endpoint URLs. Default: - No environment variables created from stack outputs

  • input (Optional[IFileSetProducer]) – FileSet to run these scripts on. The files in the FileSet will be placed in the working directory when the script is executed. Use additionalInputs to download file sets to other directories as well. Default: - No input specified

  • install_commands (Optional[Sequence[str]]) – 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. Default: - No installation commands

  • primary_output_directory (Optional[str]) – The directory that will contain the primary output fileset. After running the script, the contents of the given directory will be treated as the primary output of this Step. Default: - No primary output

Methods

add_output_directory(directory)

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 (str) –

Return type

FileSet

add_step_dependency(step)

Add a dependency on another step.

Parameters

step (Step) –

Return type

None

primary_output_directory(directory)

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 (str) –

Return type

FileSet

to_string()

Return a string representation of this Step.

Return type

str

Attributes

commands

Commands to run.

Return type

List[str]

dependencies

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

Return type

List[Step]

dependency_file_sets

The list of FileSets consumed by this Step.

Return type

List[FileSet]

env

Environment variables to set.

Default
  • No environment variables

Return type

Mapping[str, str]

env_from_cfn_outputs

Set environment variables based on Stack Outputs.

Default
  • No environment variables created from stack outputs

Return type

Mapping[str, StackOutputReference]

id

Identifier for this step.

Return type

str

inputs

Input FileSets.

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

Return type

List[FileSetLocation]

install_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.

Default
  • No installation commands

Return type

List[str]

is_source

Whether or not this is a Source step.

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

Return type

bool

outputs

Output FileSets.

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

Return type

List[FileSetLocation]

primary_output

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.

Return type

Optional[FileSet]

Static Methods

classmethod sequence(steps)

Define a sequence of steps to be executed in order.

If you need more fine-grained step ordering, use the addStepDependency() API. For example, if you want secondStep to occur after firstStep, call secondStep.addStepDependency(firstStep).

Parameters

steps (Sequence[Step]) –

Return type

List[Step]