Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Azure Pipelines allows running multiple tasks simultaneously within a single job by defining multiple parallel jobs in the pipeline. These jobs can run in parallel on different agents or on the same agent using multiple threads. To define parallel jobs, follow these steps:

  1. Define a job with a unique name using the jobs keyword.
  2. Define multiple tasks within the job.
  3. Add a strategy section within the job definition to define the number of parallel jobs, and the pool of agents to use for executing these jobs.
  4. Optionally, define dependencies between tasks to ensure that they are executed in the correct order.

Here's an example YAML definition for running two tasks in parallel:

jobs:
- job: ParallelJob
  pool:
    vmImage: 'ubuntu-latest'
  strategy:
    matrix:
      python:
        - '3.6'
        - '3.7'
      node:
        - '10.x'
        - '12.x'
  steps:
  - task: PythonTask
    displayName: 'Run Python Tests'
    inputs:
      versionSpec: '$(python)'
  - task: NodeTask
    displayName: 'Run Node Tests'
    inputs:
      versionSpec: '$(node)'
  - task: PublishTestResults@2
    displayName: 'Publish Test Results'
    inputs:
      testResultsFormat: 'JUnit'
      testResultsFiles: '**/TEST-*.xml'

In this example, two parallel jobs are defined based on the matrix strategy for Python and Node.js versions. The PythonTask and NodeTask are executed in parallel on the specified agents, and the results are published using the PublishTestResults task.