• Cloudlene Inc.

Azure DevOps: Dynamic number of Parallel Jobs

Updated: Nov 14, 2021

The below YAML takes advantage of 2 key Azure Pipeline features / characteristic.

  • When a variable is not evaluated, the entire variable string is included in the output

  • Run time expressions

#experiments.yml

trigger:
- master

variables:
 ipPattern: '10.112.20.$(System.JobPositionInPhase)' # supposed to not evaluate now but be evaluated in the step
 freshInstall: true
 noOfVMs: 15

pool: 
 vmImage: 'windows-2019'

stages:
  - stage: ActOnVMs
 displayName: 'Perform some action on VMs with contiguous IP addresses' 
 jobs:
    - job:
 strategy:
 parallel: $[variables['noOfVMs']]
 steps:
        - pwsh: Write-Host '$(System.JobPositionInPhase). $(ipPattern)'

Remember, the hosting agent only provides 1 parallel job in the free tier. You must purchase parallel jobs as necessary. Or if your team has MSDN licenses, each user gets a parallel job in your organization which you can take advantage of in self-hosted pipelines.

227 views0 comments

Recent Posts

See All