DevOps template with conditional manual approval job

0 votes

I am trying to add an approval job based on the stage, I am using a template and want to skip approval for some stages:

parameters:
- name: Stage
  type: string
- name: Environment
  type: string
- name: WebAppName
  type: string
- name: ArtifactName
  type: string
- name: DependsOn
  type: object
  default: [] 
- name: Subscription
  type: string
- name: isApproval
  type: boolean
  default: false 

stages:

############################################################
# Deploy stages
############################################################

- stage: ${{ parameters.Stage }}  
  displayName: '${{ parameters.Stage }} Stage'
  dependsOn: '${{ parameters.DependsOn }}' # this will execute based on the stage that is passed.

  jobs:
  - job: approval
    condition: eq('${{ parameters.isApproval }}', true)
    pool:
      vmImage: 'windows-latest'
    steps:
    - task: ManualIntervention@8
      timeoutInMinutes: 1440 # task times out in 1 day
      inputs:
        emailRecipients: 'example@example.com'
        instructions: 'Please validate the build configuration and resume'
            
  - deployment: ${{ parameters.Environment }} 
    ${{ if eq('${{ parameters.isApproval }}', true)}}:
      dependsOn: approval
    timeoutInMinutes: 70
    environment: '${{ parameters.Environment }} Environment'
    pool:
      vmImage: 'windows-latest'
    strategy:
      runOnce:
        deploy:
          steps:
          - task: DownloadBuildArtifacts@0
            inputs:
              buildType: 'current'
              downloadType: 'single'
              artifactName: ${{ parameters.ArtifactName }}
              downloadPath: '$(System.ArtifactsDirectory)'
          - task: AzureRmWebAppDeployment@4
            inputs:
              ConnectionType: 'AzureRM'
              azureSubscription: ${{ parameters.Subscription }} 
              appType: 'webApp'
              WebAppName: ${{ parameters.WebAppName }}
              package: '$(System.ArtifactsDirectory)/**/*.zip'

And now from the release pipeline, I am passing values to the template:

- template: stages\deploy.yml 
    parameters:
      Environment: 'Dev'
      WebAppName: 'azureappservicehelloworldapp-dev'
      Stage: 'Dev'
      ArtifactName : '$(ArtifactName)'
      Subscription: 'AzureConnectionSC'
      # empty DependsOn, as Dev depends on nothing
      DependsOn:
      - Build

  - template: stages\deploy.yml 
    parameters:
      Environment: 'UAT'
      WebAppName: 'azureappservicehelloworld-uat'
      Stage: 'UAT'
      ArtifactName : '$(ArtifactName)'
      Subscription: 'AzureConnectionSC'
      DependsOn:
      - Dev
      isApproval: true

  - template: stages\deploy.yml 
    parameters:
      Environment: 'Prod'
      WebAppName: 'azureappservicehelloworld'
      Stage: 'Prod'
      ArtifactName : '$(ArtifactName)'
      Subscription: 'AzureConnectionSC'
      DependsOn:
      - UAT
      isApproval: true

If you see IsApproval is sent as true from UAT & Prod templates, so I should be able to validate approval for UAT & prod and DEV should be deployed without any approval.

But I am getting the below error for the approval job in the template:

enter image description here

Manual intervention task is giving error, any suggestions plz.

Mar 21, 2022 in Other DevOps Questions by Kichu
• 19,040 points
1,366 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Other DevOps Questions

0 votes
1 answer

Is CCNA a big plus while applying for a DevOps job because networking knowledge comes in handy?

Hii amit, Actually now a days Cloud Computing is a ...READ MORE

answered Apr 20, 2020 in Other DevOps Questions by Niroj
• 82,840 points
2,686 views
0 votes
1 answer

How devops people communicate with QA team?

Many DevOps specialists swear by Slack as ...READ MORE

answered Oct 20, 2020 in Other DevOps Questions by Vish
520 views
0 votes
0 answers

How can a traditional SDLC be replaced with DevOps?

Jan 12, 2022 in Other DevOps Questions by Vaani
• 7,070 points
485 views
0 votes
0 answers
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP