Reputation: 243
I am using YML file to configure my azure pipelines. My pipeline can either be triggered by new commits to development branch and/or scheduled 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. 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
Upvotes: 2
Views: 1839
Reputation: 8298
We could add task bash and enter script printenv
to print all pipeline env variable. Then we could see the variable BUILD_REASON
, we can track this variable to check how the build pipeline is triggered.
Schedule is trigger from cron, IndividualCI is trigger from commit push. You could check the pic below.
Upvotes: 4