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'

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

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

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

  jobs:
  - job:

    steps:
    - 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 in Other DevOps Questions by Kichu
• 16,250 points
24 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
0 answers
0 votes
1 answer
0 votes
1 answer

Which is better azure devops or aws devops?

Hi, It depends according to your use case. ...READ MORE

answered Sep 21, 2020 in Cloud Computing by MD
• 95,340 points
1,181 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP