Class CodePipelineSource
- All Implemented Interfaces:
ICodePipelineActionFactory
,IFileSetProducer
,software.amazon.jsii.JsiiSerializable
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();
-
Nested Class Summary
Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationMode
Nested classes/interfaces inherited from interface software.amazon.awscdk.pipelines.ICodePipelineActionFactory
ICodePipelineActionFactory.Jsii$Default
Nested classes/interfaces inherited from interface software.amazon.awscdk.pipelines.IFileSetProducer
IFileSetProducer.Jsii$Default
-
Constructor Summary
ModifierConstructorDescriptionprotected
protected
CodePipelineSource
(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protected
CodePipelineSource
(software.amazon.jsii.JsiiObjectRef objRef) -
Method Summary
Modifier and TypeMethodDescriptionstatic CodePipelineSource
codeCommit
(IRepository repository, String branch) Returns a CodeCommit source.static CodePipelineSource
codeCommit
(IRepository repository, String branch, CodeCommitSourceOptions props) Returns a CodeCommit source.static CodePipelineSource
connection
(String repoString, String branch, ConnectionSourceOptions props) Returns a CodeStar connection source.static CodePipelineSource
ecr
(IRepository repository) Returns an ECR source.static CodePipelineSource
ecr
(IRepository repository, ECRSourceOptions props) Returns an ECR source.protected abstract Action
protected abstract Action
Whether or not this is a Source step.static CodePipelineSource
Returns a GitHub source, using OAuth tokens to authenticate with GitHub and a separate webhook to detect changes.static CodePipelineSource
gitHub
(String repoString, String branch, GitHubSourceOptions props) Returns a GitHub source, using OAuth tokens to authenticate with GitHub and a separate webhook to detect changes.produceAction
(IStage stage, ProduceActionOptions options) Create the desired Action and add it to the pipeline.static CodePipelineSource
Returns an S3 source.static CodePipelineSource
s3
(IBucket bucket, String objectKey, S3SourceOptions props) Returns an S3 source.sourceAttribute
(String name) Return an attribute of the current source revision.Methods inherited from class software.amazon.awscdk.pipelines.Step
addDependencyFileSet, addStepDependency, configurePrimaryOutput, discoverReferencedOutputs, getDependencies, getDependencyFileSets, getId, getPrimaryOutput, sequence, toString
Methods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSet
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Constructor Details
-
CodePipelineSource
protected CodePipelineSource(software.amazon.jsii.JsiiObjectRef objRef) -
CodePipelineSource
protected CodePipelineSource(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) -
CodePipelineSource
- 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
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 interfaceICodePipelineActionFactory
- Parameters:
stage
- This parameter is required.options
- This parameter is required.
-
sourceAttribute
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
Whether or not this is a Source step.What it means to be a Source step depends on the engine.
- Overrides:
getIsSource
in classStep
-