Skip to content
v2.274.0

ShellStep Class ​

Run shell script commands in the pipeline.

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

Example ​

ts
declare const pipeline: pipelines.CodePipeline;
const preprod = new MyApplicationStage(this, 'PreProd');
const prod = new MyApplicationStage(this, 'Prod');
const topic = new sns.Topic(this, 'ChangeApprovalTopic');

pipeline.addStage(preprod, {
  post: [
    new pipelines.ShellStep('Validate Endpoint', {
      commands: ['curl -Ssf https://my.webservice.com/'],
    }),
  ],
});
pipeline.addStage(prod, {
  pre: [new pipelines.ManualApprovalStep('PromoteToProd', {
    //All options below are optional
    comment: 'Please validate changes',
    reviewUrl: 'https://my.webservice.com/',
    notificationTopic: topic,
  })],
});
python
# pipeline: pipelines.CodePipeline

preprod = MyApplicationStage(self, "PreProd")
prod = MyApplicationStage(self, "Prod")
topic = sns.Topic(self, "ChangeApprovalTopic")

pipeline.add_stage(preprod,
    post=[
        pipelines.ShellStep("Validate Endpoint",
            commands=["curl -Ssf https://my.webservice.com/"]
        )
    ]
)
pipeline.add_stage(prod,
    pre=[pipelines.ManualApprovalStep("PromoteToProd",
        # All options below are optional
        comment="Please validate changes",
        review_url="https://my.webservice.com/",
        notification_topic=topic
    )]
)
java
CodePipeline pipeline;

MyApplicationStage preprod = new MyApplicationStage(this, "PreProd");
MyApplicationStage prod = new MyApplicationStage(this, "Prod");
Topic topic = new Topic(this, "ChangeApprovalTopic");

pipeline.addStage(preprod, AddStageOpts.builder()
        .post(List.of(
            ShellStep.Builder.create("Validate Endpoint")
                    .commands(List.of("curl -Ssf https://my.webservice.com/"))
                    .build()))
        .build());
pipeline.addStage(prod, AddStageOpts.builder()
        .pre(List.of(ManualApprovalStep.Builder.create("PromoteToProd")
                //All options below are optional
                .comment("Please validate changes")
                .reviewUrl("https://my.webservice.com/")
                .notificationTopic(topic)
                .build()))
        .build());
csharp
// Install: dotnet add package Amazon.CDK.Lib
CodePipeline pipeline;

var preprod = new MyApplicationStage(this, "PreProd");
var prod = new MyApplicationStage(this, "Prod");
var topic = new Topic(this, "ChangeApprovalTopic");

pipeline.AddStage(preprod, new AddStageOpts {
    Post = new [] {
        new ShellStep("Validate Endpoint", new ShellStepProps {
            Commands = new [] { "curl -Ssf https://my.webservice.com/" }
        }) }
});
pipeline.AddStage(prod, new AddStageOpts {
    Pre = new [] { new ManualApprovalStep("PromoteToProd", new ManualApprovalStepProps {
        //All options below are optional
        Comment = "Please validate changes",
        ReviewUrl = "https://my.webservice.com/",
        NotificationTopic = topic
    }) }
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var pipeline CodePipeline

preprod := NewMyApplicationStage(this, jsii.String("PreProd"))
prod := NewMyApplicationStage(this, jsii.String("Prod"))
topic := sns.NewTopic(this, jsii.String("ChangeApprovalTopic"))

pipeline.AddStage(preprod, &AddStageOpts{
	Post: []Step{
		pipelines.NewShellStep(jsii.String("Validate Endpoint"), &ShellStepProps{
			Commands: []*string{
				jsii.String("curl -Ssf https://my.webservice.com/"),
			},
		}),
	},
})
pipeline.AddStage(prod, &AddStageOpts{
	Pre: []Step{
		pipelines.NewManualApprovalStep(jsii.String("PromoteToProd"), &ManualApprovalStepProps{
			//All options below are optional
			Comment: jsii.String("Please validate changes"),
			ReviewUrl: jsii.String("https://my.webservice.com/"),
			NotificationTopic: topic,
		}),
	},
})

Initializer ​

ts
new ShellStep(id: string, props: ShellStepProps)
python
ShellStep(id: str, props: ShellStepProps)
java
new ShellStep(String id, ShellStepProps props)
csharp
new ShellStep(string id, ShellStepProps props)
go
NewShellStep(Id *string, Props ShellStepProps)

Properties ​

commandsstring[]commandstyping.List[str]commandsList<String>Commandsstring[]Commands*[]*stringrequired#
Commands to run.
consumedStackOutputsStackOutputReference[]consumed_stack_outputstyping.List[StackOutputReference]consumedStackOutputsList<StackOutputReference>ConsumedStackOutputsStackOutputReference[]ConsumedStackOutputs*[]StackOutputReferencerequired#
StackOutputReferences this step consumes.
dependenciesStep[]dependenciestyping.List[Step]dependenciesList<Step>DependenciesStep[]Dependencies*[]Steprequired#
Return the steps this step depends on, based on the FileSets it requires.
dependencyFileSetsFileSet[]dependency_file_setstyping.List[FileSet]dependencyFileSetsList<FileSet>DependencyFileSetsFileSet[]DependencyFileSets*[]FileSetrequired#
The list of FileSets consumed by this Step.
env{ [key: string]: string }envtyping.Mapping[str, str]envMap<String, String>EnvIDictionary<string, string>Env*map[string]*string= No environment variablesrequired#
Environment variables to set.
envFromCfnOutputs{ [key: string]: StackOutputReference }env_from_cfn_outputstyping.Mapping[str, StackOutputReference]envFromCfnOutputsMap<String, StackOutputReference>EnvFromCfnOutputsIDictionary<string, StackOutputReference>EnvFromCfnOutputs*map[string]StackOutputReference= No environment variables created…required#
Set environment variables based on Stack Outputs.
default

Default: No environment variables created from stack outputs

idstringidstridStringIdstringId*stringrequired#
Identifier for this step.
inputsFileSetLocation[]inputstyping.List[FileSetLocation]inputsList<FileSetLocation>InputsFileSetLocation[]Inputs*[]FileSetLocationrequired#
Input FileSets.

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

installCommandsstring[]install_commandstyping.List[str]installCommandsList<String>InstallCommandsstring[]InstallCommands*[]*string= No installation commandsrequired#
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.

isSourcebooleanis_sourceboolisSourceBooleanIsSourceboolIsSource*boolrequired#
Whether or not this is a Source step.

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

outputsFileSetLocation[]outputstyping.List[FileSetLocation]outputsList<FileSetLocation>OutputsFileSetLocation[]Outputs*[]FileSetLocationrequired#
Output FileSets.

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

primaryOutputFileSetprimary_outputFileSetprimaryOutputFileSetPrimaryOutputFileSetPrimaryOutputFileSet#
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.

Methods ​

addOutputDirectory(directory: string): FileSetdef add_output_directory(self, directory: str) -> FileSetpublic FileSet addOutputDirectory(String directory)public FileSet AddOutputDirectory(string directory)func AddOutputDirectory(Directory *string) FileSet#
Add an additional output FileSet based on a directory.
notes

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.

addStepDependency(step: Step): voiddef add_step_dependency(self, step: Step) -> Nonepublic void addStepDependency(Step step)public void AddStepDependency(Step step)func AddStepDependency(Step Step)#
Add a dependency on another step.
primaryOutputDirectory(directory: string): FileSetdef primary_output_directory(self, directory: str) -> FileSetpublic FileSet primaryOutputDirectory(String directory)public FileSet PrimaryOutputDirectory(string directory)func PrimaryOutputDirectory(Directory *string) 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.

sequence(steps: Step[]): Step[]@staticmethod def sequence(steps: typing.List[Step]) -> typing.List[Step]public static List<Step> sequence(List<Step> steps)public static Step[] Sequence(Step[] steps)func Sequence(Steps *[]Step) *[]Stepstatic#
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).

toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string#
Return a string representation of this Step.