【问题标题】:How can I trigger a codepipeline from codebuild not from commit?如何从代码构建而不是提交触发代码管道?
【发布时间】:2021-04-06 20:57:35
【问题描述】:

我使用 bitbucket 作为源代码控制,使用 codepipeline 作为 CI/CD 工具。我从 CDK 创建了代码管道的源操作,如下代码:

new actions.BitBucketSourceAction({
          actionName: 'SourceAction',
          owner: bitbucketOwner,
          connectionArn: codeStar,
          branch: branchName,
          output: this.sourceOutput,
          repo: bitbucketName,
        }),

codepipeline 部署完成后,当提交推送到 bitbucket 分支时会自动触发。我怎样才能阻止它这样做?我想提交以触发代码构建项目,从那里触发代码管道。

在代码管道源操作控制台中,我可以看到这个复选框:

但是如何在 CDK 中设置此配置?

【问题讨论】:

    标签: amazon-web-services bitbucket aws-codepipeline


    【解决方案1】:

    这在版本 1.95.0 中已成为可能。 BitBucketSourceActionProps 现在有triggerOnPush 参数可用。将其添加到您的 BitBucketSourceAction,值为 false

    new actions.BitBucketSourceAction({
          actionName: 'SourceAction',
          owner: bitbucketOwner,
          connectionArn: codeStar,
          branch: branchName,
          output: this.sourceOutput,
          repo: bitbucketName,
          triggerOnPush: false
        }),
    

    趣事:如果有人需要 Github 版本 2 源操作,BitBucketSourceAction 也适用于 github。不幸的是,它被 CDK 贡献者 herehere 所承认。为了尽可能避免让我的开发人员感到困惑,我使用别名导入它

    import { BitBucketSourceAction as GitHubSourceAction } from "@aws-cdk/aws-codepipeline-actions";
    
    new GitHubSourceAction({
          actionName: 'SourceAction',
          owner: githubOwner,
          connectionArn: codeStar,
          branch: branchName,
          output: this.sourceOutput,
          repo: githubRepositoryName,
          triggerOnPush: false
        }),
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-03
      • 1970-01-01
      • 2020-04-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多