【问题标题】:Mark jenkins job as success/Failed based on the status of aws codepipline execution根据 aws codepipeline 执行的状态将 jenkins 作业标记为成功/失败
【发布时间】:2020-05-22 07:18:14
【问题描述】:

我有一个 jenkins 作业,它使用执行 shell 作为构建阶段。我正在使用此 shell 中的 aws cli 命令调用 3 个 AWS Codepipeline 执行。 我的代码管道执行需要 4-5 分钟才能完成执行,但 jenkins 作业在管道完成之前被标记为成功,即使管道在任何阶段都失败了。

有没有办法让 jenkins 作业仅在代码管道执行完成后才能完成,并根据我的 aws 代码管道的状态标记 Jenkins 作业成功/失败。

如何根据我的 aws 代码管道的状态将 jenkins 作业标记为成功/失败。

【问题讨论】:

    标签: amazon-web-services jenkins jenkins-plugins aws-codepipeline


    【解决方案1】:

    'start-pipeline-execution' 是一个异步操作。您需要不断轮询执行的状态才能知道结果。

    在您的 Jenkins 作业中,当您使用 start-pipeline-execution 启动管道时,您需要使用 get-pipeline-execution CLI 调用 [1] 继续查询管道执行 ID 并继续检查状态循环中的合理时间(比如 1 小时)。当 get-pipeline-execution return status='Succeeded' 时,Jenkins 以 0 退出,如果为 'Failed',则在 shell 步骤中以 -1 退出以使 Jenkins 作业失败。

    exit -1
    

    【讨论】:

      猜你喜欢
      • 2019-06-25
      • 2019-01-18
      • 1970-01-01
      • 2011-09-18
      • 2019-07-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多