在AWS CodePipeline中,每个阶段都会有一个或多个操作(actions)。而每个操作都可以使用不同的AWS服务来完成任务,其中包括S3、CodeCommit、CodeBuild等。
要在CodePipeline中添加两个依次执行的源阶段,可以参考以下步骤:
---
Resources:
SourceRepository:
Type: AWS::CodeCommit::Repository
Properties:
RepositoryName: !Sub ${ProjectName}-repository
BuildProject:
Type: AWS::CodeBuild::Project
Properties:
Name: !Sub ${ProjectName}-build
ServiceRole: !GetAtt CodeBuildServiceRole.Arn
Source:
Type: CODEPIPELINE
Environment:
ComputeType: BUILD_GENERAL1_SMALL
Image: aws/codebuild/amazonlinux2-x86_64-standard:3.0
Type: LINUX_CONTAINER
Artifacts:
Type: CODEPIPELINE
---
Resources:
SourceRepository1:
Type: AWS::CodeCommit::Repository
Properties:
RepositoryName: !Sub ${ProjectName}-repository-1
SourceRepository2:
Type: AWS::CodeCommit::Repository
Properties:
RepositoryName: !Sub ${ProjectName}-repository-2
BuildProject:
Type: AWS::CodeBuild::Project
Properties:
Name: !Sub ${ProjectName}-build-project
ServiceRole: !GetAtt CodeBuildServiceRole.Arn
Source:
Type: CODEPIPELINE
Environment:
ComputeType: BUILD_GENERAL1_SMALL
Image: aws/codebuild/amazonlinux2-x86_64-standard:3.0
Type: LINUX_CONTAINER
Artifacts:
Type: CODEPIPELINE
Pipeline:
Type: AWS::CodePipeline::Pipeline
Properties:
Name: !Sub ${ProjectName}-pipeline
RoleArn: !GetAtt CodePipelineServiceRole.Arn
Stages:
- Name: Source1
Actions:
- Name: Source1RepoAction
ActionTypeId:
Category: Source
Owner: AWS
Version: '1'
Provider: CodeCommit
OutputArtifacts:
-