We're here to help

Parallel execution in Microsoft Azure Pipelines using targets

Microsoft Azure Pipelines is a cloud service that you can use to automatically build and test your code project and make it available to other users. It works with just about any language or project type.

Azure Pipelines combines continuous integration (CI) and continuous delivery (CD) to constantly and consistently test and build your code and ship it to any target.

This support article describes how to execute parallel execution in Azure Pipelines using targets.  

In ANT execution, everything under the target tag is executed. We can have multiple target tags present in the same build.xml file. 

In this example, we are assuming to have 20 test cases and a single build.xml file with two targets – each with 10 different test cases. The following includes instructions for using the targets of an ANT build.xml file.

 

Prerequisites


You will need to make changes to the provar.home and testproject.home variables in the build.xml file to include the path of the agent system. The following command is used to to execute the build file with targets: 

> ant -f build.xml target_name

Step 1: Configure Azure Pipelines with an ANT task. To get started, click Variables.

Step 2: Create a variable TARGETS with the value of: 

suite1,suite2

Note: The value is the name of different targets created in the build file above. It could be different for you. 

Above: View of Variables tab within Azure Pipelines. 

Step 3: Click Tasks and then the selected agent job. 

Step 4: Under Parallelism, select Multi-Configuration.

Step 5 Complete the following configuration.

Multipliers: TARGETS

Note: This is the variable name being defined at Step 2.

Maximum number of agents: Provide the number of agents you want to execute test cases in parallel.

Step 6: Select the ANT task.

Step 7: Use the following information to complete the configuration.

  • Ant build file: <Path to build file>\build.xml
  • Options: $(TARGETS)
  • Check Publish to Azure Pipelines under JUnit Test Results
  • Test results files: <Path to Result file from build.xml>\junit.xml

Step 8: Changes can also be made to the build.xml files to create separate result files. (See command below.) Otherwise, the result of one agent will override the result of the other.

<property name=”testproject.results” value=”D:\a\1\s\ANT\Results\${TARGETS}”/>

 If you execute the Azure Pipeline now, you should see that two agents are running – each executing their respective target from the build.xml file.