Created
February 14, 2020 14:14
-
-
Save raandree/eaad46b54a20bf0b98f4f91a9f6cb914 to your computer and use it in GitHub Desktop.
Parallel job execution in Azure DevOps
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trigger: | |
- '*' | |
stages: | |
- stage: develop | |
jobs: | |
- job: A | |
strategy: | |
parallel: 4 | |
pool: | |
name: 'Default' | |
workspace: | |
clean: all | |
steps: | |
- task: PowerShell@2 | |
displayName: Go1 | |
inputs: | |
targetType: inline | |
script: | | |
#Start-Sleep -Seconds 15 | |
#dir -Path env: | |
[int]$jobNumber = $env:SYSTEM_JOBPOSITIONINPHASE | |
[int]$totalJobs = $env:SYSTEM_TOTALJOBSINPHASE | |
$data = 1..100 | |
$batchSize = $data.Count / $totalJobs | |
$jobNumber-- | |
$skip = $batchSize * $jobNumber | |
$batch = $data | Select-Object -Skip $skip -First $batchSize | |
Write-Host "batchSize: $batchSize" | |
Write-Host "skip: $skip" | |
Write-Host "data: $($batch -join ' ')" | |
errorActionPreference: stop | |
- job: B | |
strategy: | |
parallel: 2 | |
pool: | |
name: 'Default' | |
workspace: | |
clean: all | |
steps: | |
- task: PowerShell@2 | |
displayName: Go1 | |
inputs: | |
targetType: inline | |
script: | | |
#Start-Sleep -Seconds 15 | |
#dir -Path env: | |
[int]$jobNumber = $env:SYSTEM_JOBPOSITIONINPHASE | |
[int]$totalJobs = $env:SYSTEM_TOTALJOBSINPHASE | |
$data = 1..100 | |
$batchSize = $data.Count / $totalJobs | |
$jobNumber-- | |
$skip = $batchSize * $jobNumber | |
$batch = $data | Select-Object -Skip $skip -First $batchSize | |
Write-Host "batchSize: $batchSize" | |
Write-Host "skip: $skip" | |
Write-Host "data: $($batch -join ' ')" | |
errorActionPreference: stop |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment