Class ShellStep

java.lang.Object
software.amazon.jsii.JsiiObject
software.amazon.awscdk.pipelines.Step
software.amazon.awscdk.pipelines.ShellStep
All Implemented Interfaces:
IFileSetProducer, software.amazon.jsii.JsiiSerializable
Direct Known Subclasses:
CodeBuildStep

@Generated(value="jsii-pacmak/1.104.0 (build e79254c)", date="2024-11-15T10:25:08.918Z") @Stability(Stable) public class ShellStep extends Step
Run shell script commands in the pipeline.

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

Example:

 Pipeline codePipeline;
 Artifact sourceArtifact = new Artifact("MySourceArtifact");
 CodePipeline pipeline = CodePipeline.Builder.create(this, "Pipeline")
         .codePipeline(codePipeline)
         .synth(ShellStep.Builder.create("Synth")
                 .input(CodePipelineFileSet.fromArtifact(sourceArtifact))
                 .commands(List.of("npm ci", "npm run build", "npx cdk synth"))
                 .build())
         .build();
 
  • Constructor Details

    • ShellStep

      protected ShellStep(software.amazon.jsii.JsiiObjectRef objRef)
    • ShellStep

      protected ShellStep(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
    • ShellStep

      @Stability(Stable) public ShellStep(@NotNull String id, @NotNull ShellStepProps props)
      Parameters:
      id - Identifier for this step. This parameter is required.
      props - This parameter is required.
  • Method Details

    • addOutputDirectory

      @Stability(Stable) @NotNull public FileSet addOutputDirectory(@NotNull String 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 - This parameter is required.
    • primaryOutputDirectory

      @Stability(Stable) @NotNull public FileSet primaryOutputDirectory(@NotNull String 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 - This parameter is required.
    • getCommands

      @Stability(Stable) @NotNull public List<String> getCommands()
      Commands to run.
    • getConsumedStackOutputs

      @Stability(Stable) @NotNull public List<StackOutputReference> getConsumedStackOutputs()
      StackOutputReferences this step consumes.
      Overrides:
      getConsumedStackOutputs in class Step
    • getEnv

      @Stability(Stable) @NotNull public Map<String,String> getEnv()
      Environment variables to set.

      Default: - No environment variables

    • getEnvFromCfnOutputs

      @Stability(Stable) @NotNull public Map<String,StackOutputReference> getEnvFromCfnOutputs()
      Set environment variables based on Stack Outputs.

      Default: - No environment variables created from stack outputs

    • getInputs

      @Stability(Stable) @NotNull public List<FileSetLocation> getInputs()
      Input FileSets.

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

    • getInstallCommands

      @Stability(Stable) @NotNull public List<String> getInstallCommands()
      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

    • getOutputs

      @Stability(Stable) @NotNull public List<FileSetLocation> getOutputs()
      Output FileSets.

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