Class CodePipelineSource
Factory for CodePipeline source steps.
Inherited Members
Namespace: Amazon.CDK.Pipelines
Assembly: Amazon.CDK.Pipelines.dll
Syntax (csharp)
public abstract class CodePipelineSource : Step, IFileSetProducer, ICodePipelineActionFactory
Syntax (vb)
Public MustInherit Class CodePipelineSource
Inherits
Step Implements IFileSetProducer, ICodePipelineActionFactory
Remarks
This class contains a number of factory methods for the different types of sources that CodePipeline supports.
ExampleMetadata: infused
Examples
// Access the CommitId of a GitHub source in the synth
var source = CodePipelineSource.GitHub("owner/repo", "main");
var pipeline = new CodePipeline(scope, "MyPipeline", new CodePipelineProps {
Synth = new ShellStep("Synth", new ShellStepProps {
Input = source,
Commands = new [] { },
Env = new Dictionary<string, string> {
{ "COMMIT_ID", source.SourceAttribute("CommitId") }
}
})
});
Synopsis
Constructors
CodePipelineSource(ByRefValue) | Used by jsii to construct an instance of this class from a Javascript-owned object reference |
CodePipelineSource(DeputyBase.DeputyProps) | Used by jsii to construct an instance of this class from DeputyProps |
CodePipelineSource(String) |
Properties
IsSource | Whether or not this is a Source step. |
Methods
CodeCommit(IRepository, String, ICodeCommitSourceOptions) | Returns a CodeCommit source. |
Connection(String, String, IConnectionSourceOptions) | Returns a CodeStar connection source. |
Ecr(IRepository, IECRSourceOptions) | Returns an ECR source. |
GetAction(Artifact_, String, Double, String) | |
GitHub(String, String, IGitHubSourceOptions) | Returns a GitHub source, using OAuth tokens to authenticate with GitHub and a separate webhook to detect changes. |
ProduceAction(IStage, IProduceActionOptions) | Create the desired Action and add it to the pipeline. |
S3(IBucket, String, IS3SourceOptions) | Returns an S3 source. |
SourceAttribute(String) | Return an attribute of the current source revision. |
Constructors
CodePipelineSource(ByRefValue)
Used by jsii to construct an instance of this class from a Javascript-owned object reference
protected CodePipelineSource(ByRefValue reference)
Parameters
- reference Amazon.JSII.Runtime.Deputy.ByRefValue
The Javascript-owned object reference
CodePipelineSource(DeputyBase.DeputyProps)
Used by jsii to construct an instance of this class from DeputyProps
protected CodePipelineSource(DeputyBase.DeputyProps props)
Parameters
- props Amazon.JSII.Runtime.Deputy.DeputyBase.DeputyProps
The deputy props
CodePipelineSource(String)
protected CodePipelineSource(string id)
Parameters
- id System.String
Identifier for this step.
Properties
IsSource
Whether or not this is a Source step.
public override bool IsSource { get; }
Property Value
System.Boolean
Overrides
Remarks
What it means to be a Source step depends on the engine.
Methods
CodeCommit(IRepository, String, ICodeCommitSourceOptions)
Returns a CodeCommit source.
public static CodePipelineSource CodeCommit(IRepository repository, string branch, ICodeCommitSourceOptions props = null)
Parameters
- repository IRepository
The CodeCommit repository.
- branch System.String
The branch to use.
- props ICodeCommitSourceOptions
The source properties.
Returns
Remarks
If you need access to symlinks or the repository history, be sure to set
codeBuildCloneOutput
.
Examples
IRepository repository;
CodePipelineSource.CodeCommit(repository, "main");
Connection(String, String, IConnectionSourceOptions)
Returns a CodeStar connection source.
public static CodePipelineSource Connection(string repoString, string branch, IConnectionSourceOptions props)
Parameters
- repoString System.String
A string that encodes owner and repository separated by a slash (e.g. 'owner/repo').
- branch System.String
The branch to use.
- props IConnectionSourceOptions
The source properties, including the connection ARN.
Returns
Remarks
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", new ConnectionSourceOptions {
ConnectionArn = "arn:aws:codestar-connections:us-east-1:222222222222:connection/7d2469ff-514a-4e4f-9003-5ca4a43cdc41"
});
If you need access to symlinks or the repository history, be sure to set
codeBuildCloneOutput
.
See: https://docs.aws.amazon.com/dtconsole/latest/userguide/welcome-connections.html
Ecr(IRepository, IECRSourceOptions)
Returns an ECR source.
public static CodePipelineSource Ecr(IRepository repository, IECRSourceOptions props = null)
Parameters
- repository IRepository
The repository that will be watched for changes.
- props IECRSourceOptions
The options, which include the image tag to be checked for changes.
Returns
Examples
IRepository repository;
CodePipelineSource.Ecr(repository, new ECRSourceOptions {
ImageTag = "latest"
});
GetAction(Artifact_, String, Double, String)
protected abstract Action GetAction(Artifact_ output, string actionName, double runOrder, string variablesNamespace = null)
Parameters
- output Artifact_
- actionName System.String
- runOrder System.Double
- variablesNamespace System.String
Returns
GitHub(String, String, IGitHubSourceOptions)
Returns a GitHub source, using OAuth tokens to authenticate with GitHub and a separate webhook to detect changes.
public static CodePipelineSource GitHub(string repoString, string branch, IGitHubSourceOptions props = null)
Parameters
- repoString System.String
- branch System.String
- props IGitHubSourceOptions
Returns
Remarks
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.
ProduceAction(IStage, IProduceActionOptions)
Create the desired Action and add it to the pipeline.
public virtual ICodePipelineActionFactoryResult ProduceAction(IStage stage, IProduceActionOptions options)
Parameters
- stage IStage
- options IProduceActionOptions
Returns
ICodePipelineActionFactoryResult
S3(IBucket, String, IS3SourceOptions)
Returns an S3 source.
public static CodePipelineSource S3(IBucket bucket, string objectKey, IS3SourceOptions props = null)
Parameters
- bucket IBucket
The bucket where the source code is located.
- objectKey System.String
The bucket where the source code is located.
- props IS3SourceOptions
The options, which include the key that identifies the source code file and and how the pipeline should be triggered.
Returns
Examples
Bucket bucket;
CodePipelineSource.S3(bucket, "path/to/file.zip");
SourceAttribute(String)
Return an attribute of the current source revision.
public virtual string SourceAttribute(string name)
Parameters
- name System.String
Returns
System.String
Remarks
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.
Examples
// Access the CommitId of a GitHub source in the synth
var source = CodePipelineSource.GitHub("owner/repo", "main");
var pipeline = new CodePipeline(scope, "MyPipeline", new CodePipelineProps {
Synth = new ShellStep("Synth", new ShellStepProps {
Input = source,
Commands = new [] { },
Env = new Dictionary<string, string> {
{ "COMMIT_ID", source.SourceAttribute("CommitId") }
}
})
});