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: Step

Run shell script commands in the pipeline.

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

ExampleMetadata

infused

Example:

# Example automatically generated from non-compiling source. May contain errors.
# 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.

consumed_stack_outputs

StackOutputReferences this step consumes.

dependencies

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

dependency_file_sets

The list of FileSets consumed by this Step.

env

Environment variables to set.

Default
  • No environment variables

env_from_cfn_outputs

Set environment variables based on Stack Outputs.

Default
  • No environment variables created from stack outputs

id

Identifier for this step.

inputs

Input FileSets.

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

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

is_source

Whether or not this is a Source step.

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

outputs

Output FileSets.

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

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.

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]