@Generated(value="jsii-pacmak/1.74.0 (build 6d08790)", date="2023-03-14T16:25:37.662Z") public abstract class CodePipelineSource extends Step implements ICodePipelineActionFactory
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();
ICodePipelineActionFactory.Jsii$Default
IFileSetProducer.Jsii$Default
Modifier | Constructor and Description |
---|---|
protected |
CodePipelineSource(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) |
protected |
CodePipelineSource(software.amazon.jsii.JsiiObjectRef objRef) |
Modifier and Type | Method and Description |
---|---|
static CodePipelineSource |
codeCommit(IRepository repository,
java.lang.String branch)
Returns a CodeCommit source.
|
static CodePipelineSource |
codeCommit(IRepository repository,
java.lang.String branch,
CodeCommitSourceOptions props)
Returns a CodeCommit source.
|
static CodePipelineSource |
connection(java.lang.String repoString,
java.lang.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 |
getAction(Artifact output,
java.lang.String actionName,
java.lang.Number runOrder) |
protected abstract Action |
getAction(Artifact output,
java.lang.String actionName,
java.lang.Number runOrder,
java.lang.String variablesNamespace) |
java.lang.Boolean |
getIsSource()
Whether or not this is a Source step.
|
static CodePipelineSource |
gitHub(java.lang.String repoString,
java.lang.String branch)
Returns a GitHub source, using OAuth tokens to authenticate with GitHub and a separate webhook to detect changes.
|
static CodePipelineSource |
gitHub(java.lang.String repoString,
java.lang.String branch,
GitHubSourceOptions props)
Returns a GitHub source, using OAuth tokens to authenticate with GitHub and a separate webhook to detect changes.
|
CodePipelineActionFactoryResult |
produceAction(IStage stage,
ProduceActionOptions options)
Create the desired Action and add it to the pipeline.
|
static CodePipelineSource |
s3(IBucket bucket,
java.lang.String objectKey)
Returns an S3 source.
|
static CodePipelineSource |
s3(IBucket bucket,
java.lang.String objectKey,
S3SourceOptions props)
Returns an S3 source.
|
java.lang.String |
sourceAttribute(java.lang.String name)
Return an attribute of the current source revision.
|
addDependencyFileSet, addStepDependency, configurePrimaryOutput, discoverReferencedOutputs, getDependencies, getDependencyFileSets, getId, getPrimaryOutput, sequence, toString
protected CodePipelineSource(software.amazon.jsii.JsiiObjectRef objRef)
protected CodePipelineSource(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
public static CodePipelineSource codeCommit(IRepository repository, java.lang.String branch, CodeCommitSourceOptions props)
If you need access to symlinks or the repository history, be sure to set
codeBuildCloneOutput
.
Example:
IRepository repository; CodePipelineSource.codeCommit(repository, "main");
repository
- The CodeCommit repository. This parameter is required.branch
- The branch to use. This parameter is required.props
- The source properties.public static CodePipelineSource codeCommit(IRepository repository, java.lang.String branch)
If you need access to symlinks or the repository history, be sure to set
codeBuildCloneOutput
.
Example:
IRepository repository; CodePipelineSource.codeCommit(repository, "main");
repository
- The CodeCommit repository. This parameter is required.branch
- The branch to use. This parameter is required.public static CodePipelineSource connection(java.lang.String repoString, java.lang.String branch, ConnectionSourceOptions props)
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
.
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.public static CodePipelineSource ecr(IRepository repository, ECRSourceOptions props)
Example:
IRepository repository; CodePipelineSource.ecr(repository, ECRSourceOptions.builder() .imageTag("latest") .build());
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.public static CodePipelineSource ecr(IRepository repository)
Example:
IRepository repository; CodePipelineSource.ecr(repository, ECRSourceOptions.builder() .imageTag("latest") .build());
repository
- The repository that will be watched for changes. This parameter is required.public static CodePipelineSource gitHub(java.lang.String repoString, java.lang.String branch, GitHubSourceOptions props)
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:
If you need access to symlinks or the repository history, use a source of type
connection
instead.
repoString
- This parameter is required.branch
- This parameter is required.props
- public static CodePipelineSource gitHub(java.lang.String repoString, java.lang.String branch)
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:
If you need access to symlinks or the repository history, use a source of type
connection
instead.
repoString
- This parameter is required.branch
- This parameter is required.public static CodePipelineSource s3(IBucket bucket, java.lang.String objectKey, S3SourceOptions props)
Example:
Bucket bucket; CodePipelineSource.s3(bucket, "path/to/file.zip");
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.public static CodePipelineSource s3(IBucket bucket, java.lang.String objectKey)
Example:
Bucket bucket; CodePipelineSource.s3(bucket, "path/to/file.zip");
bucket
- The bucket where the source code is located. This parameter is required.objectKey
- This parameter is required.protected abstract Action getAction(Artifact output, java.lang.String actionName, java.lang.Number runOrder, java.lang.String variablesNamespace)
output
- This parameter is required.actionName
- This parameter is required.runOrder
- This parameter is required.variablesNamespace
- protected abstract Action getAction(Artifact output, java.lang.String actionName, java.lang.Number runOrder)
output
- This parameter is required.actionName
- This parameter is required.runOrder
- This parameter is required.public CodePipelineActionFactoryResult produceAction(IStage stage, ProduceActionOptions options)
produceAction
in interface ICodePipelineActionFactory
stage
- This parameter is required.options
- This parameter is required.public java.lang.String sourceAttribute(java.lang.String name)
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();
name
- This parameter is required.public java.lang.Boolean getIsSource()
What it means to be a Source step depends on the engine.
getIsSource
in class Step