It's possible to detect that a build was triggered via a schedule. Based on this information, you can set certain variables or trigger certain processes.
Azure DevOps pipelines give you access to a bunch of predefined variables. In particular, 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.
ValidateShelveset: 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.
Based on this variable, it's possible to define a custom one:
variables:
${{ if eq( variables['Build.Reason'], 'Schedule' ) }}:
myCustomVariable: 'Weekly debug'
or trigger a custom process:
- task: CmdLine@2
condition: eq( variables['Build.Reason'], 'Schedule' ))
displayName: 'My scheduled script'
inputs:
script: echo "I was launched during a scheduled build"
Credit: this answer is inspired by Kevin Lu-MSFT'sanswer on Setting parameter value dynamically for automatic pipelines