I'm struggling to make Azure devops run builds in exactly the way I need it to. Right now, I have a solution where the second stage is always skipped unless the build was triggered by a schedule. This is mostly fine but is a nightmare in the rare times that we would need to run the second stage manually. Here is how I have achieved that:
- stage: second_stage
condition: eq(variables['Build.Reason'], 'Schedule')
(I can't work out how to linebreak code here!)
What I want to achieve
Please help! Thank you! <3
The following yaml can meet your request.
stages:
- stage: first_stage
jobs:
- job: A
steps:
- script: echo Hello first_stage!
- stage: second_stage
condition: or(eq(variables['Build.Reason'], 'Schedule'), eq(variables['Build.Reason'], 'Manual'))
jobs:
- job: B1
steps:
- script: echo Hello second_stage!
Only the first stage should be "checked" in the UI when a manual build is run but the user should have the option to check the second stage as well
Please manual choose which stage you want to run here when a manual build is required.