【问题标题】:How to execute command Post run in github actions?如何在 github 操作中执行命令 Post run?
【发布时间】:2021-09-08 23:43:00
【问题描述】:

有没有办法在运行后执行命令,无论之前的状态是成功还是失败,类似于 post 和 jenkinsfile 中的语法

我试过 continue-on-error: true 但这会使失败的步骤通过

【问题讨论】:

    标签: yaml workflow pipeline github-actions


    【解决方案1】:

    您可以将Job Status Check Functionsdependencies between jobs 一起使用。

    例如:

    jobs:
      job1:
        continue-on-error: true
        # Do your stuff here
      job2:
        if: ${{ always() }}
        # Execute your post run command here
    

    我创建了一个示例工作流,以在此条件下使用 continue-on-error 显示 something similar working here

    您会在该示例中看到,即使在 job2 上出现错误,之后仍会执行 job3。 这个workflow run 返回类似这样的内容(没有工作流失败并且总是在作业 3 上执行运行后命令):

    【讨论】:

      猜你喜欢
      • 2022-01-12
      • 2021-11-14
      • 2020-12-25
      • 2022-12-29
      • 2022-06-14
      • 2021-06-08
      • 2020-06-24
      • 1970-01-01
      • 2020-11-20
      相关资源
      最近更新 更多