Skip to content

Instantly share code, notes, and snippets.

@larstobi
Created December 16, 2024 12:26
Show Gist options
  • Save larstobi/4c975c7e8fa7ab94ec4172251ba23051 to your computer and use it in GitHub Desktop.
Save larstobi/4c975c7e8fa7ab94ec4172251ba23051 to your computer and use it in GitHub Desktop.
Azure pipeline failed stage manual validation
trigger:
- main
pool:
vmImage: 'ubuntu-latest'
stages:
- stage: Build
displayName: "Build Stage"
jobs:
- job: BuildJob
displayName: "Build Job"
steps:
- script: |
echo "Running build..."
# Simulate a failure by exiting with a non-zero code
exit 1
displayName: "Execute Build Script"
- stage: Deploy
displayName: "Deploy Stage"
dependsOn: Build
# Use 'always()' so that this stage runs even if previous stage failed
condition: always()
jobs:
- job: ManualValidation
displayName: "Manual Validation"
# Run this job only if the Build stage failed
condition: failed('Build')
steps:
- task: ManualValidation@0
displayName: "Manual Approval Required"
inputs:
instructions: 'The Build stage has failed. Please review the logs and click "Resume" if you wish to proceed.'
onTimeout: 'reject'
timeoutInMinutes: 1440 # 1 day timeout (optional)
- job: DeployJob
displayName: "Deploy Job"
# The Deploy job runs if the Build succeeded OR if ManualValidation succeeded after Build failed
condition: or(succeeded('Build'), succeeded('ManualValidation'))
steps:
- script: |
echo "Deploying application..."
displayName: "Execute Deployment"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment