我创建了一个堆栈,其中有用于创建管道的资源,每次在";主";分支启动了管道:
CodeCommitBranch:
Type: String
Description: branch name
Default: master
AllowedValues:
- develop
- release
- master
CodePipeline:
Type: 'AWS::CodePipeline::Pipeline'
Properties:
Name: !Sub '${Constructor}-${ApplicationID}-codepipeline'
ArtifactStore:
Location: !Ref CodePipelineS3BucketName
Type: S3
RestartExecutionOnUpdate: true
RoleArn: !Sub 'arn:aws:iam::${AWS::AccountId}:role/${CodePipelineRoleName}'
Stages:
- Name: Source
Actions:
- Name: Source
ActionTypeId:
Category: Source
Owner: AWS
Provider: CodeCommit
Version: 1
RunOrder: 1
OutputArtifacts:
- Name: SourceArtifact
Configuration:
BranchName: !Ref CodeCommitRepoBranch
PollForSourceChanges: false
RepositoryName: !GetAtt
- CodeCommitRepo
- Name
- Name: Deploy-Dev
Actions:
- Name: Deploy-Dev
ActionTypeId:
Category: Build
Owner: AWS
Provider: CodeBuild
Version: 1
RunOrder: 2
InputArtifacts:
- Name: SourceArtifact
OutputArtifacts:
- Name: DeployArtifactDev
Configuration:
ProjectName: !Ref CodeDeployDev
- Name: Deploy-Int
Actions:
- Name: IntPromotionApproval
ActionTypeId:
Category: Approval
Owner: AWS
Provider: Manual
Version: 1
RunOrder: 3
- Name: Deploy-Int
ActionTypeId:
Category: Build
Owner: AWS
Provider: CodeBuild
Version: 1
RunOrder: 31
InputArtifacts:
- Name: SourceArtifact
OutputArtifacts:
- Name: DeployArtifactInt
Configuration:
ProjectName: !Ref CodeDeployInt
我想知道当"推送"发生时,是否有可能在启动同一管道的同一资源中添加一个操作;开发";树枝因此,最终管道在两种情况下都启动;主";并且在";开发";。
AWS CodePipeline还不支持多分支管道配置。因此,理想情况下,您需要为develop
分支创建另一个管道。
您的管道配置了CloudWatch事件。CloudWatch event rule
会自动为您的管道配置
{
"source": [
"aws.codecommit"
],
"detail-type": [
"CodeCommit Repository State Change"
],
"resources": [
"arn:aws:codecommit:us-west-2:80398EXAMPLE:MyTestRepo"
],
"detail": {
"referenceType": [
"branch"
],
"referenceName": [
"master",
"develop"
]
}
}
如果以上事件规则是用您的管道配置的,那么它会触发master
和develop
分支更改。但是您的管道是为主分支配置的。因此,在CodeBuild中,您的主分支内容将在CODEBUILD_SRC_DIR
位置中可用
CODEBUILD_SRC_DIR CODEBUILD用于生成的目录路径(例如,/tmp/src12345689/src(。
要为两个分支使用单个管道,则需要在buildspec.yml
文件中开发并添加自己的逻辑,以签出到开发分支,然后在那里执行构建。
通常您不会尝试为多个分支使用同一管道进行构建。触发器是对分支的推送,该分支触发一个Cloud Watch事件,该事件反过来启动管道的其余部分。因此,从许多不同的分支尝试踢开管道是不好的。