【问题标题】:How to create an AWS Cloudwatch event that runs Codebuild when a pull request is created in CodeCommit?在 CodeCommit 中创建拉取请求时,如何创建运行 Codebuild 的 AWS Cloudwatch 事件?
【发布时间】:2021-09-14 07:23:10
【问题描述】:

我想创建一个 Cloudwatch 事件,每次在 CodeCommit 分支上发出拉取请求时运行 Codebuild 项目。但是,我所做的事件不会在主分支上创建拉取请求时触发。希望大家能给我一些建议。

下面是我制定的事件规则的事件模式:

{
  "source": [
    "aws.codecommit"
  ],
  "detail-type": [
    "CodeCommit Pull Request State Change"
  ],
  "resources": [
    "arn:aws:codecommit:XX-XX-1:XXX:dev-test"
  ],
  "detail": {
    "event": [
      "pullRequestCreated"
    ],
    "referenceType": [
      "branch"
    ],
    "referenceName": [
      "master"
    ]
  }
}

【问题讨论】:

    标签: amazon-web-services amazon-cloudwatch


    【解决方案1】:

    您的活动在我看来不合适。我会尝试使用:

    {
      "source": [
        "aws.codecommit"
      ],
      "detail-type": [
        "CodeCommit Pull Request State Change"
      ],
      "detail": {
        "event": [
          "pullRequestCreated"
        ],
        "repositoryNames": [
          "<your-repo>"
        ]
      }
    }
    

    【讨论】:

    • 谢谢,它成功了!是否也可以添加分支名称?
    • @h2o 没问题。很高兴它有效。您可以添加 PR 的源分支。 "sourceReference": "refs/heads/&lt;branch-name&gt;"
    猜你喜欢
    • 2018-12-23
    • 2023-02-07
    • 2018-10-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-22
    • 2011-12-13
    • 1970-01-01
    相关资源
    最近更新 更多