期望的行为如下:
所需的解决方案将有两个管道,第二个管道由第一个管道的成功触发。
如果您有任何其他想法,我很高兴听到!
提前致谢
假设两个 CodePipelines 在同一个帐户中运行。您可以在 buildspec.yml 中添加“post_build”阶段。
在 post_build 阶段,您可以使用 AWS SDK 命令触发第二个 CodePipeline。
build:
commands:
# npm pack --dry-run is not needed but helps show what is going to be published
- npm publish
post_build:
commands:
- aws codepipeline start-pipeline-execution --name <codepipeline_name>
我建议的第二个管道触发器的解决方案如下:
为了保持清洁,请为每个管道使用单独的桶。
我在这个帖子中使用了 Amin 的答案,因为它对于特定用例来说是一个非常简单的解决方案。
- aws codepipeline start-pipeline-execution --name <codepipeline_name>
除此之外,您可能还需要在 IAM 中为尝试触发所需管道的代码构建角色添加 管道执行 权限。
IAM 政策示例:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"codepipeline:StartPipelineExecution"
],
"Resource": "arn:aws:codepipeline:<region>:<account-id>:<pipeline-name>"
}
]
}