# Overview

This article provides instructions on how to create a Universal Agent in qTest Launch 1.3 and beyond.

IMPORTANT: We recommend using the Universal Agent as opposed to the legacy Shell Agent.

# Create a New Universal Agent

1. From Launch, open the host machine where you want to create the new agent and then select the + New Agent icon.
2. You will be presented with a New Agent dialog.
3. Enter the following information for the new agent:

• Agent Name: name of the new agent
• qTest Manager Project: select a qTest Manager project from which the agent is going to execute scheduled tests
• Agent Type: Universal Agent

# Pre-Execute Script

This section provides an editor for you to compose scripts that will execute when the Universal Agent is kicked-off.

Enter scripts you want the Universal Agent to execute. One common practice is outlined below:

• Setup a working directory for your automation project.
• Pull, checkout, or clone the source code of your automation project from the source control to the working directory.

Examples: pull source code of your automation project from git repository to your working directory. If the directory or the source code does not exist, create the directory and clone the source code into that directory. Below script is how you can archive it on Linux, Mac or Windows.

Linux/Mac

#!/bin/bash
if [ ! -d "/path/to/working/dir/my-project" ]
then
# move to working dir
cd "/path/to/working/dir"
# clone the repo to the working directory
git clone <repo-url>
else # the working project already exists
# move to working dir
cd /path/to/working/dir
# pull latest code
git pull --all
fi


Windows

if not exist "\path\to\working\dir\my-project" (
cd /d "\path\to\working\dir"
git clone <repo-url>
) else (
cd /d "\path\to\working\dir"
git pull --all
)


# Execute Command

### Executor

Executor specifies the execution environment, or program, that executes your commands. Possible values are:

• shell: select this option if you want Universal Agent to execute your commands as shell scripts. This option is only available if your host is running on Linux or Mac
• batch: select this option if you want Universal Agent to execute your commands as batch scripts. This option is only available if your host is running on Windows
• node: select this option if you want your command to be executed as a nodejs program.
Note:  starting from Automation Host 2.1.0, NodeJS is bundled into automation host package so you do NOT need to install NodeJS to the host machine in order to execute your command with selected node executor. However, you need to make sure the code you enter is compatible with that nodejs version
• python: select this option if you want your command to be executed as a python program.
Note: If you are on Mac, python 2.7 was pre-installed already with MacOS. Otherwise, you need to install python to the host machine in order for Automation Host to invoked it to execute your python scripts. You can download and install python from here: https://www.python.org/downloads
• python3: select this option if you want your command to be executed as a python3 program.

### Working Directory

This field is optional. However, it is highly recommended to select the working directory where you want your execute command to execute.

Example: /path/to/working/dir/my-project

### Execute Command

This is where you enter the commands to execute your test project.

Example: configure execute command to execute your test project using maven

• Executor: shell
• Working Directory: /path/to/working/dir/my-project
• Execute Command:
# execute test with maven
mvn clean compile package test


### Path to Results

If you are configuring the execute command to execute tests, which is the main use case of Universal Agent, Path to Results is where you specify path to the test results generated by your test project.

This optional field is used in combination of Result Parser (more detail later) to parse the results to the unified format that the Automation Host could understand. Path to Results accepts one of the followings:

• Path to your test result file. Example: /path/to/working/dir/postman-api-test/postman-result.json
• The directory where all of your results are located

### Result Parser

This optional field specifies the parser that transforms the test results to an unified format. The output of the parser will then be used by the Automation Host to submit test result to qTest Manager.

Below are possible options for Result Parser:

• JUnit for Java: select this parser to parse your JUnit test result
• Postman Json: select this parser to parse Postman test result
• Tosca Junit: select this parser to parse Tosca test result

IMPORTANT NOTE

• If you want the Universal Agent to submit test results to qTest Manager, you must  specify values for both Path to Results and Result Parser. Otherwise, you must do that yourself via Execute Command.

The screenshot below shows you how the new Universal Agent is configured.

## Appendix

### Pre-Execute Scripts Examples

This section provide examples to be used as pre-execute scripts. You can select any of the example in this section and it will be appended to the Pre-Execute Script editor. Screenshot below show how git clone example looks like when you click on it.