Skip to content
v2.274.0

FileSet Class ​

A set of files traveling through the deployment pipeline.

Individual steps in the pipeline produce or consume FileSets.

Example ​

ts
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 };
  }
}
python
@jsii.implements(pipelines.ICodePipelineActionFactory)
class MyJenkinsStep(pipelines.Step):
    def __init__(self, provider, input):
        super().__init__("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.
        self.discover_referenced_outputs({
            "env": {}
        })

    def produce_action(self, stage, *, scope, actionName, runOrder, variablesNamespace=None, artifacts, fallbackArtifact=None, pipeline, codeBuildDefaults=None, beforeSelfMutation=None, stackOutputsMap):
        # This is where you control what type of Action gets added to the
        # CodePipeline
        stage.add_action(
            cpactions.JenkinsAction(
                # Copy 'actionName' and 'runOrder' from the options
                action_name=action_name,
                run_order=run_order,

                # Jenkins-specific configuration
                type=cpactions.JenkinsActionType.TEST,
                jenkins_provider=self.provider,
                project_name="MyJenkinsProject",

                # Translate the FileSet into a codepipeline.Artifact
                inputs=[artifacts.to_code_pipeline(self.input)]
            ))

        return pipelines.CodePipelineActionFactoryResult(run_orders_consumed=1)
java
public class MyJenkinsStep extends Step implements ICodePipelineActionFactory {
    public MyJenkinsStep(JenkinsProvider provider, FileSet input) {
        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(Map.of(
                "env", Map.of()));
    }

    public CodePipelineActionFactoryResult produceAction(IStage stage, ProduceActionOptions options) {
        // This is where you control what type of Action gets added to the
        // CodePipeline
        stage.addAction(
        JenkinsAction.Builder.create()
                // Copy 'actionName' and 'runOrder' from the options
                .actionName(options.getActionName())
                .runOrder(options.getRunOrder())

                // Jenkins-specific configuration
                .type(JenkinsActionType.TEST)
                .jenkinsProvider(this.provider)
                .projectName("MyJenkinsProject")

                // Translate the FileSet into a codepipeline.Artifact
                .inputs(List.of(options.artifacts.toCodePipeline(this.input)))
                .build());

        return CodePipelineActionFactoryResult.builder().runOrdersConsumed(1).build();
    }
}
csharp
// Install: dotnet add package Amazon.CDK.Lib
class MyJenkinsStep : Step, ICodePipelineActionFactory
{
    public MyJenkinsStep(JenkinsProvider provider, FileSet input) : base("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.
        DiscoverReferencedOutputs(new Dictionary<string, IDictionary<string, object>> {
            { "env", new Struct { } }
        });
    }

    public CodePipelineActionFactoryResult ProduceAction(IStage stage, ProduceActionOptions options)
    {
        // This is where you control what type of Action gets added to the
        // CodePipeline
        stage.AddAction(
        new JenkinsAction(new JenkinsActionProps {
            // Copy 'actionName' and 'runOrder' from the options
            ActionName = options.ActionName,
            RunOrder = options.RunOrder,

            // Jenkins-specific configuration
            Type = JenkinsActionType.TEST,
            JenkinsProvider = Provider,
            ProjectName = "MyJenkinsProject",

            // Translate the FileSet into a codepipeline.Artifact
            Inputs = new [] { options.Artifacts.ToCodePipeline(Input) }
        }));

        return new CodePipelineActionFactoryResult { RunOrdersConsumed = 1 };
    }
}
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
type myJenkinsStep struct {
	Step
}

func newMyJenkinsStep(provider JenkinsProvider, input FileSet) *myJenkinsStep {
	this := &myJenkinsStep{}
	pipelines.NewStep_Override(this, jsii.String("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(map[string]map[string]interface{}{
		"env": map[string]interface{}{
		},
	})
	return this
}

func (this *myJenkinsStep) produceAction(stage IStage, options ProduceActionOptions) CodePipelineActionFactoryResult {
	// This is where you control what type of Action gets added to the
	// CodePipeline
	*stage.AddAction(
	cpactions.NewJenkinsAction(&JenkinsActionProps{
		// Copy 'actionName' and 'runOrder' from the options
		ActionName: options.ActionName,
		RunOrder: options.RunOrder,

		// Jenkins-specific configuration
		Type: cpactions.JenkinsActionType_TEST,
		JenkinsProvider: this.provider,
		ProjectName: jsii.String("MyJenkinsProject"),

		// Translate the FileSet into a codepipeline.Artifact
		Inputs: []Artifact{
			options.Artifacts.ToCodePipeline(this.input),
		},
	}))

	return &CodePipelineActionFactoryResult{
		RunOrdersConsumed: jsii.Number(1),
	}
}

Initializer ​

ts
new FileSet(id: string, producer?: Step)
python
FileSet(id: str, producer: typing.Optional[Step] = None)
java
new FileSet(String id, Step producer)
csharp
new FileSet(string id, Step? producer = null)
go
NewFileSet(Id *string, Producer Step)

Properties ​

idstringidstridStringIdstringId*stringrequired#
Human-readable descriptor for this file set (does not need to be unique).
primaryOutputFileSetprimary_outputFileSetprimaryOutputFileSetPrimaryOutputFileSetPrimaryOutputFileSet#
The primary output of a file set producer.

The primary output of a FileSet is itself.

producerStepproducerStepproducerStepProducerStepProducerSteprequired#
The Step that produces this FileSet.

Methods ​

producedBy(producer?: Step): voiddef produced_by(self, producer: typing.Optional[Step] = None) -> Nonepublic void producedBy(Step producer)public void ProducedBy(Step? producer = null)func ProducedBy(Producer Step)#
Mark the given Step as the producer for this FileSet.

This method can only be called once.

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