首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >AWS CodeBuild网络钩子- CloudFormation

AWS CodeBuild网络钩子- CloudFormation
EN

Stack Overflow用户
提问于 2020-07-28 22:22:18
回答 2查看 1.6K关注 0票数 0

我知道我们可以从AWS控制台启用CodeBuild钩子,但是我们能在yml中启用来自cloudformation的webhook吗?

codebuild.yml

代码语言:javascript
运行
复制
Resources:
  
  CodeBuildProject:
    Type: AWS::CodeBuild::Project
    DependsOn:
      - CodeBuildSourceCredential
    .
    .
    Properties:
      Source:
        Type: GITHUB
        Location: https://github.com/path/project.git
        BuildSpec: buildspec.yml
      .
      .

      Triggers:
        Webhook: true
        FilterGroups:
          - - Type: EVENT
              Pattern: PUSH

  CodeBuildSourceCredential:
    Type: 'AWS::CodeBuild::SourceCredential'
    Properties: 
      Token: '<TokenString>'
      ServerType: GITHUB
      AuthType: PERSONAL_ACCESS_TOKEN

我试图创建这个堆栈,但它似乎不起作用,堆栈因此错误而失败。

代码语言:javascript
运行
复制
Failed to call CreateWebhook, reason: Unable to create webhook at this time. Please try again later. (Service: AWSCodeBuild; Status Code: 400; Error Code: OAuthProviderException; Request ID: xxxxxx-5ddf-xxxx-88a1-xxxxxx; Proxy: null)
EN

回答 2

Stack Overflow用户

发布于 2020-07-30 18:21:36

下面是一个示例CloudFormation模板片段:

代码语言:javascript
运行
复制
Resources:
  Project:
    Type: AWS::CodeBuild::Project
    Properties:
      Name: CFN-Project
      # Other properties ............................................
      Source:
        Location: https://github.com/shariqmus/private-repo.git
        Type: GITHUB
        Auth:
          Type: OAUTH
          Resource: !Ref GitHubToken # Personal Access Token
      SourceVersion: master   # Branch name
      Triggers:
        Webhook: true
        FilterGroups:
          - - Type: EVENT
              Pattern: PUSH
              ExcludeMatchedPattern: false
            - Type: HEAD_REF
              Pattern: refs/heads/master # 'master' is Branch name
              ExcludeMatchedPattern: false
票数 4
EN

Stack Overflow用户

发布于 2020-07-29 00:17:43

根据错误消息,您似乎还没有设置AWS::CodeBuild::SourceCredential,您的问题也没有提供有关使用该资源的任何细节。

AWS::CodeBuild::SourceCredential是GitHub、GitHub企业或Bitbucket所必需的:

有关用于、GitHub企业或Bitbucket存储库的GitHub凭据的信息。我们强烈建议您使用AWS秘密管理器来存储凭据。

创建AWS::CodeBuild::SourceCredential后,必须使CodeBuildProject 依赖于凭据。例如:

代码语言:javascript
运行
复制
  MySourceCreds:
    Type: 'AWS::CodeBuild::SourceCredential'
    # other parameters

  CodeBuildProject:
    Type: AWS::CodeBuild::Project
    DependsOn: MySourceCreds
    # other parameters
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63143638

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档