要在独立的Codebuild作业中使用AWS Codestar Bitbucket连接作为源提供程序,需要在Codepipeline中设置一个支持Bitbucket连接的项目,并在Codebuild作业中引用该项目。以下是示例代码:
在Codepipeline中设置项目:
Resources:
BitBucketConnection:
Type: AWS::CodeStarConnections::Connection
Properties:
ConnectionName: my-bitbucket-conn
ProviderType: Bitbucket
OwnerAccountId: 123456789012
ConnectionArn: arn:aws:codestar-connections:us-east-1:123456789012:connection/my-bitbucket-conn
SourceCode:
Type: AWS::CodeStarSourceConnection::Code
Properties:
ConnectionArn: !GetAtt BitBucketConnection.Arn
Location: https://bitbucket.org/user/repo.git
Type: Bitbucket
在Codebuild作业中添加项目引用:
Environment:
ComputeType: BUILD_GENERAL1_SMALL
Image: aws/codebuild/standard:3.0
Type: LINUX_CONTAINER
PrivilegedMode: true
Source:
Type: CODEPIPELINE
BuildSpec: buildspec.yml
GitCloneDepth: 1
ReportBuildStatus: true
GitSubmodulesConfig:
FetchSubmodules: false
Artifacts:
Type: CODEPIPELINE
此示例代码演示了如何在Codepipeline中设置一个支持Bitbucket连接的项目,并在Codebuild作业中引用该项目。通过这种方式,AWS Codestar Bitbucket连接可作为Codebuild作业的源提供程序选择。