I have an Azure DevOps system up and running, with triggers to run the pipeline due to PRs as well as a nightly schedule, like so:
trigger:
batch: true
branches:
include:
- main
- release/*
- pre-release/*
schedules:
- cron: "0 0 * * *"
displayName: Daily midnight build
branches:
include:
#- main
#- release/*
- pre-release/*
always: false
Is there a way to let the job know that's being called from a Schedule rather than a PR? I'd like to add another series of more rigorous tests, but just with nightlies, as part of the usual job.
Perhaps setting a variable that can be checked later in the pipeline.
You could use the Build.Reason predefined variable.
In your case checking if $(Build.Reason) equals Schedule should work.
Build.Reason. The event that caused the build to run.
Manual: A user manually queued the build.IndividualCI: Continuous integration (CI) triggered by a Git push or a TFVC check-in.BatchedCI: Continuous integration (CI) triggered by a Git push or a TFVC check-in, and the Batch changes was selected.Schedule: Scheduled trigger.ValidateShelvese: A user manually queued the build of a specific TFVC shelveset.CheckInShelveset: Gated check-in trigger.PullRequest: The build was triggered by a Git branch policy that requires a build.ResourceTrigger: The build was triggered by a resource trigger or it was triggered by another build.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With