【问题标题】:How do I know where a pipeline is running because of schedule or trigger由于计划或触发器,我如何知道管道在哪里运行
【发布时间】:2023-03-14 14:33:01
【问题描述】:

在 Azure DevOps YAML 中,我可以指定管道基于计划或触发器运行:

trigger:
  batch: true
  branches:
    include:
      - develop

schedules:
- cron: "0 0 * * *"
  displayName: Daily 9pm
  branches:
    include:
    - develop

在 YAML 中,如何检测管道是否由于计划而不是触发器而运行?我可以在条件中使用变量吗?我想要这个的原因是我想安排一个通宵部署,然后运行端到端测试。

【问题讨论】:

    标签: azure-devops yaml


    【解决方案1】:

    我可以在条件中使用变量吗?

    当然,是的。我们提供了一个predefined variable 名称Build.Reason 可以让您知道当前管道的触发类型。

    只需像下面这样配置条件:

     - bash: |
        echo "run test"
       condition: eq(variables['Build.Reason'], 'Schedule') ## run this task when the pipeline is triggered due to schedule.
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-17
      • 2021-04-28
      • 1970-01-01
      • 2022-10-12
      • 2019-05-24
      • 2014-03-23
      相关资源
      最近更新 更多