[英]How to track what triggered my pipeline on Azure DevOps?
I am using YML file to configure my azure pipelines.我正在使用 YML 文件来配置我的 azure 管道。 My pipeline can either be triggered by new commits to development branch and/or scheduled cron.
我的管道可以由对开发分支和/或计划的 cron 的新提交触发。 How can I track which triggered the pipeline?
如何跟踪哪个触发了管道? I wanted to do some task based on what triggered by pipeline, whether from a new commit or a cron.
我想根据管道触发的内容执行一些任务,无论是新提交还是 cron。 It's a small add-on task, so I am avoiding writing a new pipeline to separate the tasks.
这是一个小的附加任务,所以我避免编写一个新的管道来分离任务。 Thanks in advance!
提前致谢!
Here is my code sample:这是我的代码示例:
trigger:
- development
schedules:
- cron: '0 0 * * *' # will run midnight every day
displayName: 'Midnight tests' (UTC - 7:00)'
branches:
include:
- development
always: true
stages:
### do some work
We could add task bash and enter script printenv
to print all pipeline env variable.我们可以添加任务 bash 并输入脚本
printenv
来打印所有管道环境变量。 Then we could see the variable BUILD_REASON
, we can track this variable to check how the build pipeline is triggered.然后我们可以看到变量
BUILD_REASON
,我们可以跟踪这个变量来检查构建管道是如何触发的。
Schedule is trigger from cron, IndividualCI is trigger from commit push. schedule 是由 cron 触发的,IndividualCI 是由提交推送触发的。 You could check the pic below.
你可以查看下面的图片。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.