2

我设置了一个 AWS CodePipeline,它使用 github 作为源,CodeBuild 用于构建,并部署到 ElasticBeanstalk。

当一切都在控制台中设置好并且我是 github 帐户的管理员时,我能够让它工作(我使用不同的帐户进行测试)

我需要部署的实际代码属于我不是管理员的帐户,因此按照本指南,我收到了个人访问令牌并使用 CLI 更新了 CodePipeline。

一旦我使用 cli 更新了项目,它就不会在提交代码时被触发。

我不确定发生了什么变化,因为即使我使用控制台并将 webhook 直接设置为我正在测试的 github 帐户的管理员,它仍然无法正常工作。

这是我更新管道的 json:

{
    "pipeline": {
        "roleArn": "arn:aws:iam::xxxxxxx:role/service-role/AWSCodePipelineServiceRole-us-west-2-xxxxx-xxxx", 
        "stages": [
            {
                "name": "Source", 
                "actions": [
                    {
                        "inputArtifacts": [], 
                        "name": "Source", 
                        "actionTypeId": {
                            "category": "Source", 
                            "owner": "ThirdParty", 
                            "version": "1", 
                            "provider": "GitHub"
                        }, 
                        "outputArtifacts": [
                            {
                                "name": "SourceArtifact"
                            }
                        ], 
                        "configuration": {
                            "Owner": "xxx", 
                            "Repo": "xxx", 
                            "PollForSourceChanges": "false", 
                            "Branch": "stage"
                        }, 
                        "runOrder": 1
                    }
                ]
            }, 
            {
                "name": "Build", 
                "actions": [
                    {
                        "inputArtifacts": [
                            {
                                "name": "SourceArtifact"
                            }
                        ], 
                        "name": "Build", 
                        "actionTypeId": {
                            "category": "Build", 
                            "owner": "AWS", 
                            "version": "1", 
                            "provider": "CodeBuild"
                        }, 
                        "outputArtifacts": [
                            {
                                "name": "BuildArtifact"
                            }
                        ], 
                        "configuration": {
                            "ProjectName": "xxx-stage-codebuild"
                        }, 
                        "runOrder": 1
                    }
                ]
            }, 
            {
                "name": "Deploy", 
                "actions": [
                    {
                        "inputArtifacts": [
                            {
                                "name": "BuildArtifact"
                            }
                        ], 
                        "name": "Deploy", 
                        "actionTypeId": {
                            "category": "Deploy", 
                            "owner": "AWS", 
                            "version": "1", 
                            "provider": "ElasticBeanstalk"
                        }, 
                        "outputArtifacts": [], 
                        "configuration": {
                            "ApplicationName": "xxx", 
                            "EnvironmentName": "xxx-stage"
                        }, 
                        "runOrder": 1
                    }
                ]
            }
        ], 
        "artifactStore": {
            "type": "S3", 
            "location": "xxx-artifacts-stage"
        }, 
        "name": "xxx-stage", 
        "version": 15
    }
}
4

1 回答 1

2

要修复更新的 GitHub 源的 webhook,您需要执行以下步骤:

  1. 使用 [1] 中的步骤取消注册并删除与旧 GitHub 存储库关联的现有 webhook。

  2. 使用 [2] 中的步骤重新创建 webhook。

参考:

[1] 删除 GitHub 源的 Webhook - https://docs.aws.amazon.com/codepipeline/latest/userguide/pipelines-webhooks-delete.html

[2] 为 GitHub 源创建 Webhook - https://docs.aws.amazon.com/codepipeline/latest/userguide/pipelines-webhooks-create.html

如果您遇到任何挑战,请告诉我。

于 2019-11-05T11:43:55.413 回答