aws-cdk-lib.pipelines.Step

class Step

LanguageType name
.NETAmazon.CDK.Pipelines.Step
Gogithub.com/aws/aws-cdk-go/awscdk/v2/pipelines#Step
Javasoftware.amazon.awscdk.pipelines.Step
Pythonaws_cdk.pipelines.Step
TypeScript (source)aws-cdk-lib » pipelines » Step

Implements IFileSetProducer

Implemented by CodeBuildStep, ConfirmPermissionsBroadening, ManualApprovalStep, ShellStep

A generic Step which can be added to a Pipeline.

Steps can be used to add Sources, Build Actions and Validations to your pipeline.

This class is abstract. See specific subclasses of Step for useful steps to add to your Pipeline

Example

class MyJenkinsStep extends pipelines.Step implements pipelines.ICodePipelineActionFactory {
  constructor(
    private readonly provider: cpactions.JenkinsProvider,
    private readonly input: pipelines.FileSet,
  ) {
    super('MyJenkinsStep');

    // This is necessary if your step accepts parameters, like environment variables,
    // that may contain outputs from other steps. It doesn't matter what the
    // structure is, as long as it contains the values that may contain outputs.
    this.discoverReferencedOutputs({
      env: { /* ... */ }
    });
  }

  public produceAction(stage: codepipeline.IStage, options: pipelines.ProduceActionOptions): pipelines.CodePipelineActionFactoryResult {

    // This is where you control what type of Action gets added to the
    // CodePipeline
    stage.addAction(new cpactions.JenkinsAction({
      // Copy 'actionName' and 'runOrder' from the options
      actionName: options.actionName,
      runOrder: options.runOrder,

      // Jenkins-specific configuration
      type: cpactions.JenkinsActionType.TEST,
      jenkinsProvider: this.provider,
      projectName: 'MyJenkinsProject',

      // Translate the FileSet into a codepipeline.Artifact
      inputs: [options.artifacts.toCodePipeline(this.input)],
    }));

    return { runOrdersConsumed: 1 };
  }
}

Initializer

new Step(id: string)

Parameters

  • id string — Identifier for this step.

Properties

NameTypeDescription
consumedStackOutputsStackOutputReference[]StackOutputReferences this step consumes.
dependenciesStep[]Return the steps this step depends on, based on the FileSets it requires.
dependencyFileSetsFileSet[]The list of FileSets consumed by this Step.
idstringIdentifier for this step.
isSourcebooleanWhether or not this is a Source step.
primaryOutput?FileSetThe primary FileSet produced by this Step.

consumedStackOutputs

Type: StackOutputReference[]

StackOutputReferences this step consumes.


dependencies

Type: Step[]

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


dependencyFileSets

Type: FileSet[]

The list of FileSets consumed by this Step.


id

Type: string

Identifier for this step.


isSource

Type: boolean

Whether or not this is a Source step.

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


primaryOutput?

Type: FileSet (optional)

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

NameDescription
addStepDependency(step)Add a dependency on another step.
toString()Return a string representation of this Step.
protected addDependencyFileSet(fs)Add an additional FileSet to the set of file sets required by this step.
protected configurePrimaryOutput(fs)Configure the given FileSet as the primary output of this step.
protected discoverReferencedOutputs(structure)Crawl the given structure for references to StepOutputs and add dependencies on all steps found.
static sequence(steps)Define a sequence of steps to be executed in order.

addStepDependency(step)

public addStepDependency(step: Step): void

Parameters

  • step Step

Add a dependency on another step.


toString()

public toString(): string

Returns

  • string

Return a string representation of this Step.


protected addDependencyFileSet(fs)

protected addDependencyFileSet(fs: FileSet): void

Parameters

  • fs FileSet

Add an additional FileSet to the set of file sets required by this step.

This will lead to a dependency on the producer of that file set.


protected configurePrimaryOutput(fs)

protected configurePrimaryOutput(fs: FileSet): void

Parameters

  • fs FileSet

Configure the given FileSet as the primary output of this step.


protected discoverReferencedOutputs(structure)

protected discoverReferencedOutputs(structure: any): void

Parameters

  • structure any

Crawl the given structure for references to StepOutputs and add dependencies on all steps found.

Should be called in the constructor of subclasses based on what the user passes in as construction properties. The format of the structure passed in here does not have to correspond exactly to what gets rendered into the engine, it just needs to contain the same data.


static sequence(steps)

public static sequence(steps: Step[]): Step[]

Parameters

  • steps Step[]

Returns

  • Step[]

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