我如何知道由于计划或触发器而在哪里运行管道

时间:2020-07-09 01:29:50

标签: azure-devops yaml

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

trigger:
  batch: true
  branches:
    include:
      - develop

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

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

1 个答案:

答案 0 :(得分:0)

是否可以在条件中使用变量?

当然可以。我们提供了一个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.