Class CodePipelineSource

java.lang.Object
software.amazon.jsii.JsiiObject
software.amazon.awscdk.pipelines.Step
software.amazon.awscdk.pipelines.CodePipelineSource
All Implemented Interfaces:
ICodePipelineActionFactory, IFileSetProducer, software.amazon.jsii.JsiiSerializable

@Generated(value="jsii-pacmak/1.84.0 (build 5404dcf)", date="2023-06-19T16:30:49.800Z") @Stability(Stable) public abstract class CodePipelineSource extends Step implements ICodePipelineActionFactory
Factory for CodePipeline source steps.

This class contains a number of factory methods for the different types of sources that CodePipeline supports.

Example:

 // Access the CommitId of a GitHub source in the synth
 CodePipelineSource source = CodePipelineSource.gitHub("owner/repo", "main");
 CodePipeline pipeline = CodePipeline.Builder.create(scope, "MyPipeline")
         .synth(ShellStep.Builder.create("Synth")
                 .input(source)
                 .commands(List.of())
                 .env(Map.of(
                         "COMMIT_ID", source.sourceAttribute("CommitId")))
                 .build())
         .build();
 
  • Constructor Details

    • CodePipelineSource

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

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

      @Stability(Stable) protected CodePipelineSource(@NotNull String id)
      Parameters:
      id - Identifier for this step. This parameter is required.
  • Method Details

    • codeCommit

      @Stability(Stable) @NotNull public static CodePipelineSource codeCommit(@NotNull IRepository repository, @NotNull String branch, @Nullable CodeCommitSourceOptions props)
      Returns a CodeCommit source.

      If you need access to symlinks or the repository history, be sure to set codeBuildCloneOutput.

      Example:

       IRepository repository;
       CodePipelineSource.codeCommit(repository, "main");
       

      Parameters:
      repository - The CodeCommit repository. This parameter is required.
      branch - The branch to use. This parameter is required.
      props - The source properties.
    • codeCommit

      @Stability(Stable) @NotNull public static CodePipelineSource codeCommit(@NotNull IRepository repository, @NotNull String branch)
      Returns a CodeCommit source.

      If you need access to symlinks or the repository history, be sure to set codeBuildCloneOutput.

      Example:

       IRepository repository;
       CodePipelineSource.codeCommit(repository, "main");
       

      Parameters:
      repository - The CodeCommit repository. This parameter is required.
      branch - The branch to use. This parameter is required.
    • connection

      @Stability(Stable) @NotNull public static CodePipelineSource connection(@NotNull String repoString, @NotNull String branch, @NotNull ConnectionSourceOptions props)
      Returns a CodeStar connection source.

      A CodeStar connection allows AWS CodePipeline to access external resources, such as repositories in GitHub, GitHub Enterprise or BitBucket.

      To use this method, you first need to create a CodeStar connection using the AWS console. In the process, you may have to sign in to the external provider -- GitHub, for example -- to authorize AWS to read and modify your repository. Once you have done this, copy the connection ARN and use it to create the source.

      Example:

       CodePipelineSource.connection("owner/repo", "main", ConnectionSourceOptions.builder()
               .connectionArn("arn:aws:codestar-connections:us-east-1:222222222222:connection/7d2469ff-514a-4e4f-9003-5ca4a43cdc41")
               .build());
       

      If you need access to symlinks or the repository history, be sure to set codeBuildCloneOutput.

      Parameters:
      repoString - A string that encodes owner and repository separated by a slash (e.g. 'owner/repo'). This parameter is required.
      branch - The branch to use. This parameter is required.
      props - The source properties, including the connection ARN. This parameter is required.
      See Also:
    • ecr

      @Stability(Stable) @NotNull public static CodePipelineSource ecr(@NotNull IRepository repository, @Nullable ECRSourceOptions props)
      Returns an ECR source.

      Example:

       IRepository repository;
       CodePipelineSource.ecr(repository, ECRSourceOptions.builder()
               .imageTag("latest")
               .build());
       

      Parameters:
      repository - The repository that will be watched for changes. This parameter is required.
      props - The options, which include the image tag to be checked for changes.
    • ecr

      @Stability(Stable) @NotNull public static CodePipelineSource ecr(@NotNull IRepository repository)
      Returns an ECR source.

      Example:

       IRepository repository;
       CodePipelineSource.ecr(repository, ECRSourceOptions.builder()
               .imageTag("latest")
               .build());
       

      Parameters:
      repository - The repository that will be watched for changes. This parameter is required.
    • gitHub

      @Stability(Stable) @NotNull public static CodePipelineSource gitHub(@NotNull String repoString, @NotNull String branch, @Nullable GitHubSourceOptions props)
      Returns a GitHub source, using OAuth tokens to authenticate with GitHub and a separate webhook to detect changes.

      This is no longer the recommended method. Please consider using connection() instead.

      Pass in the owner and repository in a single string, like this:

       CodePipelineSource.gitHub("owner/repo", "main");
       

      Authentication will be done by a secret called github-token in AWS Secrets Manager (unless specified otherwise).

      The token should have these permissions:

      • repo - to read the repository
      • admin:repo_hook - if you plan to use webhooks (true by default)

      If you need access to symlinks or the repository history, use a source of type connection instead.

      Parameters:
      repoString - This parameter is required.
      branch - This parameter is required.
      props -
    • gitHub

      @Stability(Stable) @NotNull public static CodePipelineSource gitHub(@NotNull String repoString, @NotNull String branch)
      Returns a GitHub source, using OAuth tokens to authenticate with GitHub and a separate webhook to detect changes.

      This is no longer the recommended method. Please consider using connection() instead.

      Pass in the owner and repository in a single string, like this:

       CodePipelineSource.gitHub("owner/repo", "main");
       

      Authentication will be done by a secret called github-token in AWS Secrets Manager (unless specified otherwise).

      The token should have these permissions:

      • repo - to read the repository
      • admin:repo_hook - if you plan to use webhooks (true by default)

      If you need access to symlinks or the repository history, use a source of type connection instead.

      Parameters:
      repoString - This parameter is required.
      branch - This parameter is required.
    • s3

      @Stability(Stable) @NotNull public static CodePipelineSource s3(@NotNull IBucket bucket, @NotNull String objectKey, @Nullable S3SourceOptions props)
      Returns an S3 source.

      Example:

       Bucket bucket;
       CodePipelineSource.s3(bucket, "path/to/file.zip");
       

      Parameters:
      bucket - The bucket where the source code is located. This parameter is required.
      objectKey - This parameter is required.
      props - The options, which include the key that identifies the source code file and and how the pipeline should be triggered.
    • s3

      @Stability(Stable) @NotNull public static CodePipelineSource s3(@NotNull IBucket bucket, @NotNull String objectKey)
      Returns an S3 source.

      Example:

       Bucket bucket;
       CodePipelineSource.s3(bucket, "path/to/file.zip");
       

      Parameters:
      bucket - The bucket where the source code is located. This parameter is required.
      objectKey - This parameter is required.
    • getAction

      @Stability(Stable) @NotNull protected abstract Action getAction(@NotNull Artifact output, @NotNull String actionName, @NotNull Number runOrder, @Nullable String variablesNamespace)
      Parameters:
      output - This parameter is required.
      actionName - This parameter is required.
      runOrder - This parameter is required.
      variablesNamespace -
    • getAction

      @Stability(Stable) @NotNull protected abstract Action getAction(@NotNull Artifact output, @NotNull String actionName, @NotNull Number runOrder)
      Parameters:
      output - This parameter is required.
      actionName - This parameter is required.
      runOrder - This parameter is required.
    • produceAction

      @Stability(Stable) @NotNull public CodePipelineActionFactoryResult produceAction(@NotNull IStage stage, @NotNull ProduceActionOptions options)
      Create the desired Action and add it to the pipeline.

      Specified by:
      produceAction in interface ICodePipelineActionFactory
      Parameters:
      stage - This parameter is required.
      options - This parameter is required.
    • sourceAttribute

      @Stability(Stable) @NotNull public String sourceAttribute(@NotNull String name)
      Return an attribute of the current source revision.

      These values can be passed into the environment variables of pipeline steps, so your steps can access information about the source revision.

      Pipeline synth step has some source attributes predefined in the environment. If these suffice, you don't need to use this method for the synth step.

      Example:

       // Access the CommitId of a GitHub source in the synth
       CodePipelineSource source = CodePipelineSource.gitHub("owner/repo", "main");
       CodePipeline pipeline = CodePipeline.Builder.create(scope, "MyPipeline")
               .synth(ShellStep.Builder.create("Synth")
                       .input(source)
                       .commands(List.of())
                       .env(Map.of(
                               "COMMIT_ID", source.sourceAttribute("CommitId")))
                       .build())
               .build();
       

      Parameters:
      name - This parameter is required.
      See Also:
    • getIsSource

      @Stability(Stable) @NotNull public Boolean getIsSource()
      Whether or not this is a Source step.

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

      Overrides:
      getIsSource in class Step