if Syntax in Azure DevOps YAML

0 votes
I have a pool of self-hosted VMs half of which is dedicated to installing & testing an 'ON' build and an 'OFF' build. All my test agent VMs have 'ALL' as a user-defined capability. Half of them are also tagged 'ON', and the other half 'OFF'.
Now I have 2 stages called DEPLOY OFF & DEPLOY ON that can be skipped if a Variable Group variable 'skipDeployOffStage' or 'skipDeployOnStage' is set to true. I would like to use 'ALL' as an agent demand if only ON / OFF is to be tested. If both ON & OFF are to be tested, the appropriate stage would demand their respective 'ON' or 'OFF' VMs.
Question: The ${{ if }} DOES NOT WORK.
trigger: none
pr: none

pool: 'MyBuildPool'

  - name: subPool
    value: 'ON'
  - name: useAllPool
    value: $[ or(eq( variables.skipDeployOnStage, true), eq( variables.skipDeployOffStage, true)) ]
- stage: DEPLOYOFF
  condition: ne(variables['skipDeployOffStage'], 'true')

    # The test stage's subpool
    ${{ if variables.useAllPool }}:
      subPool: 'ALL'
    ${{ if not(variables.useAllPool)  }}:
      subPool: 'OFF'

    name: 'MyTestPool'
      - ${{ variables.subPool }}

  - job:

    - checkout: none
    - pwsh: |
        Write-Host ("Value of useAllPool is: {0}" -f '$(useAllPool)')
        Write-Host ("Value of VG variable 'skipDeployOnStage' is {0} and 'skipDeployOffStage' is {1}" -f '$(skipDeployOnStage)', '$(skipDeployOffStage)')
        Write-Host ("Subpool is {0}" -f '$(subPool)')
      displayName: 'Determined SubPool'

The Output when one of the flags is false:

2020-08-02T18:39:05.5849160Z Value of useAllPool is: True
2020-08-02T18:39:05.5854283Z Value of VG variable 'skipDeployOnStage' is true and 'skipDeployOffStage' is false
2020-08-02T18:39:05.5868711Z Subpool is ALL
The Output when both are false:
2020-08-02T18:56:40.5371875Z Value of useAllPool is: False
2020-08-02T18:56:40.5383258Z Value of VG variable 'skipDeployOnStage' is false and 'skipDeployOffStage' is false
2020-08-02T18:56:40.5386626Z Subpool is ALL

Why is it not working?
Mar 25, 2022 in Other DevOps Questions by Kichu
• 19,050 points

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
0 answers
0 votes
1 answer

Azure DevOps yaml passing variable using "##vso[task.setvariable" not working

You can stop the pipeline from running ...READ MORE

answered Feb 8, 2022 in Other DevOps Questions by Bhavitha
• 1,000 points
0 votes
2 answers

Which is better azure devops or aws devops?

Azure DevOps, a part of Microsoft's cloud ...READ MORE

answered Jan 8 in Cloud Computing by anonymous
• 700 points
0 votes
1 answer
0 votes
1 answer

What is the Difference between VSO, VSTS and Azure Devops

Azure DevOps was previously known as VSO ...READ MORE

answered Mar 8, 2022 in Azure by Edureka
• 13,620 points

edited Jun 27, 2023 by Khan Sarfaraz 1,401 views
0 votes
1 answer

How can I preview PowerPoint files in Azure DevOps (VSTS)?

For work item attachments, there are no ...READ MORE

answered Mar 8, 2022 in DevOps & Agile by gaurav
• 23,260 points
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP