# Overview

This article provides instructions on how to create a Universal Agent in the qTest Automation Host. We recommend using the Universal Agent as opposed to the legacy Shell Agent.

# Create a New Universal Agent

2. You will be presented with a New Agent dialog.

3. Enter the information listed below 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 to be executed when the Universal Agent is kicked-off.

Enter scripts you want the Universal Agent to execute. One common practice is to do the following:

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

Example:

• 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/bashif [ ! -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 --allfi


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

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

• shell: select this option if you want the Universal Agent to execute your commands as shell scripts. Select this option 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. Select this option 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 the automation host package so you do NOT need to install NodeJS to the host machine in order to execute your command with the selected node executor. However, you do need to make sure that 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: this option is recommended for Automation Host running on Mac machine, as python 2.7 was pre-installed with MacOS.
• python3: select this option if you want your command to be executed as Python3 program. This option is recommended if the automation host is running on either Linux, Windows or Mac.

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

Here, you enter the commands to execute your test project.

Example: configure execute commands 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 for the Universal Agent, Path to Results is where you specify a path to the test results generated by your test project.

This optional field is used in combination with the Result Parser (more detail later) to parse the results to the unified format that the Automation Host understands. 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.
• Example:

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 obtained by the Automation Host to submit test result to qTest Manager as test run logs.

Below are possible options for Result Parser:

• JUnit for Java: select this parser to parse test results under JUnit format
• Postman Json: select this parser to parse test results generated by Postman under Json format
• Tosca JUnit: select this parser to parse test resulst generated by Tosca under JUnit format

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 fields. Otherwise, you must do that yourself via the Execute Command.

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

# Appendix

### Pre-Execute Scripts Examples

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