# ConnectionSourceOptions

Configuration options for CodeStar source.

- Source: [`pipelines/lib/codepipeline/codepipeline-source.ts`](https://github.com/aws/aws-cdk/blob/v2.277.0/packages/aws-cdk-lib/pipelines/lib/codepipeline/codepipeline-source.ts#L378)
- Type last changed: v2.64.0 · 9 Feb 2023

## Example

TypeScript:

```ts
const pipeline = new pipelines.CodePipeline(this, 'Pipeline', {
  synth: new pipelines.ShellStep('Synth', {
    input: pipelines.CodePipelineSource.connection('my-org/my-app', 'main', {
      connectionArn:
        'arn:aws:codestar-connections:us-east-1:222222222222:connection/7d2469ff-514a-4e4f-9003-5ca4a43cdc41', // Created using the AWS console * });',
    }),
    commands: ['npm ci', 'npm run build', 'npx cdk synth'],
  }),

  // Turn this on because the pipeline uses Docker image assets
  dockerEnabledForSelfMutation: true,
});

pipeline.addWave('MyWave', {
  post: [
    new pipelines.CodeBuildStep('RunApproval', {
      commands: ['command-from-image'],
      buildEnvironment: {
        // The user of a Docker image asset in the pipeline requires turning on
        // 'dockerEnabledForSelfMutation'.
        buildImage: codebuild.LinuxBuildImage.fromAsset(this, 'Image', {
          directory: './docker-image',
        }),
      },
    }),
  ],
});
```

Python:

```python
pipeline = pipelines.CodePipeline(self, "Pipeline",
    synth=pipelines.ShellStep("Synth",
        input=pipelines.CodePipelineSource.connection("my-org/my-app", "main",
            connection_arn="arn:aws:codestar-connections:us-east-1:222222222222:connection/7d2469ff-514a-4e4f-9003-5ca4a43cdc41"
        ),
        commands=["npm ci", "npm run build", "npx cdk synth"]
    ),

    # Turn this on because the pipeline uses Docker image assets
    docker_enabled_for_self_mutation=True
)

pipeline.add_wave("MyWave",
    post=[
        pipelines.CodeBuildStep("RunApproval",
            commands=["command-from-image"],
            build_environment=codebuild.BuildEnvironment(
                # The user of a Docker image asset in the pipeline requires turning on
                # 'dockerEnabledForSelfMutation'.
                build_image=codebuild.LinuxBuildImage.from_asset(self, "Image",
                    directory="./docker-image"
                )
            )
        )
    ]
)
```

Java:

```java
CodePipeline pipeline = CodePipeline.Builder.create(this, "Pipeline")
        .synth(ShellStep.Builder.create("Synth")
                .input(CodePipelineSource.connection("my-org/my-app", "main", ConnectionSourceOptions.builder()
                        .connectionArn("arn:aws:codestar-connections:us-east-1:222222222222:connection/7d2469ff-514a-4e4f-9003-5ca4a43cdc41")
                        .build()))
                .commands(List.of("npm ci", "npm run build", "npx cdk synth"))
                .build())

        // Turn this on because the pipeline uses Docker image assets
        .dockerEnabledForSelfMutation(true)
        .build();

pipeline.addWave("MyWave", WaveOptions.builder()
        .post(List.of(
            CodeBuildStep.Builder.create("RunApproval")
                    .commands(List.of("command-from-image"))
                    .buildEnvironment(BuildEnvironment.builder()
                            // The user of a Docker image asset in the pipeline requires turning on
                            // 'dockerEnabledForSelfMutation'.
                            .buildImage(LinuxBuildImage.fromAsset(this, "Image", DockerImageAssetProps.builder()
                                    .directory("./docker-image")
                                    .build()))
                            .build())
                    .build()))
        .build());
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
var pipeline = new CodePipeline(this, "Pipeline", new CodePipelineProps {
    Synth = new ShellStep("Synth", new ShellStepProps {
        Input = CodePipelineSource.Connection("my-org/my-app", "main", new ConnectionSourceOptions {
            ConnectionArn = "arn:aws:codestar-connections:us-east-1:222222222222:connection/7d2469ff-514a-4e4f-9003-5ca4a43cdc41"
        }),
        Commands = new [] { "npm ci", "npm run build", "npx cdk synth" }
    }),

    // Turn this on because the pipeline uses Docker image assets
    DockerEnabledForSelfMutation = true
});

pipeline.AddWave("MyWave", new WaveOptions {
    Post = new [] {
        new CodeBuildStep("RunApproval", new CodeBuildStepProps {
            Commands = new [] { "command-from-image" },
            BuildEnvironment = new BuildEnvironment {
                // The user of a Docker image asset in the pipeline requires turning on
                // 'dockerEnabledForSelfMutation'.
                BuildImage = LinuxBuildImage.FromAsset(this, "Image", new DockerImageAssetProps {
                    Directory = "./docker-image"
                })
            }
        }) }
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
pipeline := pipelines.NewCodePipeline(this, jsii.String("Pipeline"), &CodePipelineProps{
	Synth: pipelines.NewShellStep(jsii.String("Synth"), &ShellStepProps{
		Input: pipelines.CodePipelineSource_Connection(jsii.String("my-org/my-app"), jsii.String("main"), &ConnectionSourceOptions{
			ConnectionArn: jsii.String("arn:aws:codestar-connections:us-east-1:222222222222:connection/7d2469ff-514a-4e4f-9003-5ca4a43cdc41"),
		}),
		Commands: []*string{
			jsii.String("npm ci"),
			jsii.String("npm run build"),
			jsii.String("npx cdk synth"),
		},
	}),

	// Turn this on because the pipeline uses Docker image assets
	DockerEnabledForSelfMutation: jsii.Boolean(true),
})

pipeline.AddWave(jsii.String("MyWave"), &WaveOptions{
	Post: []Step{
		pipelines.NewCodeBuildStep(jsii.String("RunApproval"), &CodeBuildStepProps{
			Commands: []*string{
				jsii.String("command-from-image"),
			},
			BuildEnvironment: &BuildEnvironment{
				// The user of a Docker image asset in the pipeline requires turning on
				// 'dockerEnabledForSelfMutation'.
				BuildImage: codebuild.LinuxBuildImage_FromAsset(this, jsii.String("Image"), &DockerImageAssetProps{
					Directory: jsii.String("./docker-image"),
				}),
			},
		}),
	},
})
```

## Properties

- `actionName`: string — The action name used for this source in the CodePipeline.

  **Default:** The repository string

- `codeBuildCloneOutput`: boolean = false — If this is set, the next CodeBuild job clones the repository (instead of CodePipeline downloading the files).

  This provides access to repository history, and retains symlinks (symlinks would otherwise be
  removed by CodePipeline).

  **Note**: if this option is true, only CodeBuild jobs can use the output artifact.

- `connectionArn`: string (required) — The ARN of the CodeStar Connection created in the AWS console that has permissions to access this GitHub or BitBucket repository.

  ```ts
  'arn:aws:codestar-connections:us-east-1:123456789012:connection/12345678-abcd-12ab-34cdef5678gh'
  ```

- `triggerOnPush`: boolean = true — Controls automatically starting your pipeline when a new commit is made on the configured repository and branch.

  If unspecified,
  the default value is true, and the field does not display by default.
