# CodePipelineFileSet

A FileSet created from a CodePipeline artifact.

You only need to use this if you want to add CDK Pipeline stages
add the end of an existing CodePipeline, which should be very rare.

Extends: [FileSet](/cdk/api/v2/docs/aws-cdk-lib.pipelines.FileSet.html) › CodePipelineFileSet
Implements: [IFileSetProducer](/cdk/api/v2/docs/aws-cdk-lib.pipelines.IFileSetProducer.html)
Obtainable from: CodePipelineFileSet.fromArtifact

- Source: [`pipelines/lib/codepipeline/artifact-map.ts`](https://github.com/aws/aws-cdk/blob/v2.277.0/packages/aws-cdk-lib/pipelines/lib/codepipeline/artifact-map.ts#L71)

## Example

TypeScript:

```ts
declare const codePipeline: codepipeline.Pipeline;

const sourceArtifact = new codepipeline.Artifact('MySourceArtifact');

const pipeline = new pipelines.CodePipeline(this, 'Pipeline', {
  codePipeline: codePipeline,
  synth: new pipelines.ShellStep('Synth', {
    input: pipelines.CodePipelineFileSet.fromArtifact(sourceArtifact),
    commands: ['npm ci', 'npm run build', 'npx cdk synth'],
  }),
});
```

Python:

```python
# code_pipeline: codepipeline.Pipeline

source_artifact = codepipeline.Artifact("MySourceArtifact")

pipeline = pipelines.CodePipeline(self, "Pipeline",
    code_pipeline=code_pipeline,
    synth=pipelines.ShellStep("Synth",
        input=pipelines.CodePipelineFileSet.from_artifact(source_artifact),
        commands=["npm ci", "npm run build", "npx cdk synth"]
    )
)
```

Java:

```java
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();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
Pipeline codePipeline;

var sourceArtifact = new Artifact("MySourceArtifact");

var pipeline = new CodePipeline(this, "Pipeline", new CodePipelineProps {
    CodePipeline = codePipeline,
    Synth = new ShellStep("Synth", new ShellStepProps {
        Input = CodePipelineFileSet.FromArtifact(sourceArtifact),
        Commands = new [] { "npm ci", "npm run build", "npx cdk synth" }
    })
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var codePipeline Pipeline

sourceArtifact := codepipeline.NewArtifact(jsii.String("MySourceArtifact"))

pipeline := pipelines.NewCodePipeline(this, jsii.String("Pipeline"), &CodePipelineProps{
	CodePipeline: codePipeline,
	Synth: pipelines.NewShellStep(jsii.String("Synth"), &ShellStepProps{
		Input: pipelines.CodePipelineFileSet_FromArtifact(sourceArtifact),
		Commands: []*string{
			jsii.String("npm ci"),
			jsii.String("npm run build"),
			jsii.String("npx cdk synth"),
		},
	}),
})
```

## Properties

- `id`: string — Human-readable descriptor for this file set (does not need to be unique).

- `primaryOutput`: [FileSet](/cdk/api/v2/docs/aws-cdk-lib.pipelines.FileSet.html) — The primary output of a file set producer.

  The primary output of a FileSet is itself.

- `producer`: [Step](/cdk/api/v2/docs/aws-cdk-lib.pipelines.Step.html) — The Step that produces this FileSet.

## Methods

- `fromArtifact(artifact: Artifact): CodePipelineFileSet // chainable` (static) — Turn a CodePipeline Artifact into a FileSet.

- `producedBy(producer?: Step): void` — Mark the given Step as the producer for this FileSet.

  This method can only be called once.

- `toString(): string` — Return a string representation of this FileSet.
