github - 使用第三方 GitHub 源提供程序为 AWS Pipeline 保留 git 操作
问题描述
我有一个配置为使用 ThridParty GitHub 源提供程序的管道,如下所示:
...
Resources:
DevPipeline:
Type: AWS::CodePipeline::Pipeline
Properties:
Name: my-pipeline
RoleArn: !Ref 'PipelineRole'
Stages:
- Name: Source
Actions:
- Name: GitHub
ActionTypeId:
Category: Source
Owner: ThirdParty
Version: 1
Provider: GitHub
Configuration:
Owner: !Ref GitHubOwner
Repo: !Ref GitHubRepo
Branch: !Ref GitHubBranch
OAuthToken: !Ref GitHubToken
OutputArtifacts:
- Name: JavaSource
RunOrder: 1
...
我希望能够git
在以下构建步骤中对源代码运行操作。但是,此源操作不包括.git
输出工件中的文件夹。
如何修改它以便我可以访问git
repo 上的操作?
解决方案
CodePipeline 最近发布了新版本的 GitHub Source 操作,该操作执行 git 存储库的实际克隆,而不是从 GitHub 获取“zip”包。
新的 GitHub 操作(版本 2)使用 CodeStarSourceConnection。因此,我们只需要在管道的源阶段指定 CodeStarSourceConnection [1] 源操作提供程序。CloudFormation 还支持 AWS::CodeStarConnections::Connection 资源 [2]。您可以引用现有 Connection 的 ARN,或在 CloudFormation 中创建一个新的。现有连接可在此处找到 [0]。
这是一个示例模板片段:
Resources:
CodeStarConnection:
Type: 'AWS::CodeStarConnections::Connection'
Properties:
ConnectionName: MyGitHubConnection
ProviderType: GitHub
CodePipeline:
Type: 'AWS::CodePipeline::Pipeline'
Properties:
Stages:
- Name: Source
Actions:
- Name: SourceAction
ActionTypeId:
Category: Source
Owner: AWS
Version: 1
Provider: CodeStarSourceConnection
OutputArtifacts:
- Name: SourceArtifact
Configuration:
ConnectionArn: !Ref CodeStarConnection
BranchName: master
FullRepositoryId: username/repository
RunOrder: 1
... ...
注意:通过 CloudFormation 创建的连接默认处于 PENDING 状态。您可以通过更新控制台 [3] 中的连接来使其状态为 AVAILABLE。连接可用后,您可以将 CodePipeline 与 Github 版本 2 源操作一起使用。
参考:
[0] 连接 - https://console.aws.amazon.com/codesuite/settings/connections
[1] CodeStarSourceConnection - https://docs.aws.amazon.com/codepipeline/latest/userguide/action-reference-CodestarConnectionSource.html
[2] AWS::CodeStarConnections::Connection - https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-codestarconnections-connection.html
[3] 更新挂起的连接 - https://docs.aws.amazon.com/dtconsole/latest/userguide/connections-update.html
推荐阅读
- python - url pattern-data 中的 NoReverseMatch 是元组形式
- google-chrome - MediaStreamTrack 停止方法不起作用。它被弃用了吗?
- javascript - 如何从 JavaScript 呈现的响应页面下载最高分辨率的图像?
- drupal-8 - 规则 - 如何检查用户是否有角色
- php - 在 localhost 中运行代码日历 google 但不能在在线服务器中运行
- matplotlib - '语法错误:关键字不能是表达式
- node.js - 为什么 pm2 日志在 Node js 中不显示实时?
- xml - Twilio:从 XML 获取数字
- html - 使用 SpringMVC 的 @PathVariable 时,Thymeleaf 无法解析静态资源
- javascript - 如何在特定时间偏移处将动画 SVG 绘制到画布上?