# ShellStep

Run shell script commands in the pipeline.

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

Extends: Step › ShellStep
Implements: IFileSetProducer
Superclass of: CodeBuildStep

- Source: [`pipelines/lib/blueprint/shell-step.ts`](https://github.com/aws/aws-cdk/blob/v2.274.0/packages/aws-cdk-lib/pipelines/lib/blueprint/shell-step.ts#L99)
- Type last changed: v2.60.0 · 12 Jan 2023

## 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,
  })],
});
```

## Initializer

```ts
new ShellStep(id: string, props: ShellStepProps)
```

## Properties

- `commands`: string[] (required) — Commands to run.

- `consumedStackOutputs`: [StackOutputReference](/cdk/api/v2/docs/aws-cdk-lib.pipelines.StackOutputReference.html)[] (required) — StackOutputReferences this step consumes.

- `dependencies`: [Step](/cdk/api/v2/docs/aws-cdk-lib.pipelines.Step.html)[] (required) — Return the steps this step depends on, based on the FileSets it requires.

- `dependencyFileSets`: [FileSet](/cdk/api/v2/docs/aws-cdk-lib.pipelines.FileSet.html)[] (required) — The list of FileSets consumed by this Step.

- `env`: { [key: string]: string } (required) = No environment variables — Environment variables to set.

- `envFromCfnOutputs`: { [key: string]: [StackOutputReference](/cdk/api/v2/docs/aws-cdk-lib.pipelines.StackOutputReference.html) } (required) = No environment variables created from stack outputs — Set environment variables based on Stack Outputs.

  **Default:** No environment variables created from stack outputs

- `id`: string (required) — Identifier for this step.

- `inputs`: [FileSetLocation](/cdk/api/v2/docs/aws-cdk-lib.pipelines.FileSetLocation.html)[] (required) — Input FileSets.

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

- `installCommands`: string[] (required) = 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`.

- `isSource`: boolean (required) — Whether or not this is a Source step.

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

- `outputs`: [FileSetLocation](/cdk/api/v2/docs/aws-cdk-lib.pipelines.FileSetLocation.html)[] (required) — Output FileSets.

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

- `primaryOutput`: [FileSet](/cdk/api/v2/docs/aws-cdk-lib.pipelines.FileSet.html) — 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): 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.

- `addStepDependency(step: Step): void` — Add a dependency on another step.

- `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[]` (static) — 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(): string` — Return a string representation of this Step.
