【问题标题】:Can I make my CodePipeline only executed when triggered manually我可以让我的 CodePipeline 仅在手动触发时执行吗
【发布时间】:2019-04-07 19:25:07
【问题描述】:

我有一个 CodePipeline 设置。但是现在我只想让我的管道在我手动触发它时运行,这可能吗?

【问题讨论】:

标签: amazon-web-services aws-codepipeline


【解决方案1】:

您可以使用 CloudWatch Events,永远不会触发您的管道:

https://docs.aws.amazon.com/codepipeline/latest/userguide/pipelines-trigger-source-schedule-console.html

设置will never execute 的cronjob,然后您可以随时通过单击“发布更改”按钮手动触发管道。 我还没有测试过,但我认为它应该可以工作。

【讨论】:

  • 我还能用这种方法从我的 git 存储库中轮询吗?
【解决方案2】:

您需要将 CodePipeline 配置为由 CloudWatch 事件触发。完成此操作后,将在 CloudWatch 下创建一个名为“codepipeline-{repository_name}”的事件规则。

禁用此规则将阻止 CodePipeline 被 CodeCommit 触发。当您需要构建时,只需单击“发布更改”按钮。

【讨论】:

    【解决方案3】:

    这对我有用:

    使用 Github webhook 设置常规管道。 这将创建并注册一个内部 aws webhook。 然后只需通过 aws-cli 注销并删除 webhook like it is written in the aws docs

    根据您所在的地区调整以下内容,我的是 us-east-2:

    找出 webhook 的名称:

    aws codepipeline list-webhooks
    

    注销:

    aws codepipeline deregister-webhook-with-third-party --webhook-name <webhook-name>
    

    删除:

    aws codepipeline delete-webhook --name <webhook-name>
    

    注意: 必须将源步骤配置为使用 Github webhook

    现在您可以通过 AWS 控制台或通过 aws-cli 手动触发管道:

    aws codepipeline start-pipeline-execution --name <pipeline-name>
    

    【讨论】:

    • 是的,这很有效,就像一个魅力!应该是正确答案!只是 --endpoint-url--region 不是必需的,它们在新 API 中不存在。 aws codepipeline list-webhooks 就够了。再次感谢!
    猜你喜欢
    • 2015-03-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-21
    • 1970-01-01
    • 2014-12-26
    • 2012-07-04
    • 2011-03-20
    相关资源
    最近更新 更多