In order to make the integration in your Java Maven projects easier, we have developed the Xray-Maven-Plugin. It enables the upload of your Tests directly to Xray with a single Maven command.
The plugin supports single or multi-module projects and multiple test frameworks. With the execution of a single Maven target com.xpandit.xray:xray-maven-plugin:xray, the plugin will upload the results of the tests to your Jira instance.
List of Available Properties
Please note
The user present in the properties below must exist in the JIRA instance and have permission to Create Test and Test Execution Issues
Property Name | Required (-Yes,-Optional) | Description | Examples |
---|---|---|---|
xray.jiraURL | Full URL of Jira, including the relative path, if its being used | http://localhost:8080 | |
xray.resultsFormat | Results format. Available formats: JUNIT. (more on format specifics in Import Execution Results - REST) case sensitive | JUNIT | |
xray.username | Jira Username | admin | |
xray.password | Jira Password plain-text only | password | |
xray.projectKey | Jira Project Key | MYPROJKEY | |
xray.testExecKey | Test Execution Issue ID | MYT2-5 | |
xray.testPlanKey | Test Plan Issue ID | MYT2-54 | |
xray.testEnvironments | Test Environment | iOS | |
xray.fixVersion | Fix Version. It supports only one value. | Release 1.0 | |
xray.revision | Revision | 1234 | |
xray.surefire.location | Folder with .xml files or xml file to be uploaded | ${basedir}/target/surefire-reports/TEST-com.xpandit.xray.service.ResultImporterTest.xml ${basedir}/target/surefire-reports |
Please note
You may configure the plugin properties in your project pom.xml, the settings.xml file (see project guidelines below) or via the console with -D option (e.g., -Dxray.projectKey=PROJ).
List of Available Result Formats
Each result format points to a specific Xray REST Endpoint where the results are imported. The result format is configured in the property xray.resultsFormat and is case-sensitive.
Results Format (xray.resultsFormat) | Description |
---|---|
JUNIT | JUnit XML output format (more information regarding its endpoint here) |
Build, Test and Upload Results
mvn clean package surefire:test com.xpandit.xray:xray-maven-plugin:xray
Upload Results Only
mvn com.xpandit.xray:xray-maven-plugin:xray
Maven Project Guidelines
Standard Environment Configuration
<?xml version="1.0" encoding="UTF-8"?> <settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd" xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <!-- OTHER CONFS--> <profiles> <profile> <!-- OTHER CONFS--> <properties> <xray.jiraURL>http://localhost:8080</xray.jiraURL> <xray.resultsFormat>JUNIT</xray.resultsFormat> <xray.username>admin</xray.username> <xray.password>password</xray.password> </properties> <id>MyActiveProfile</id> </profile> </profiles> <activeProfiles> <activeProfile>MyActiveProfile</activeProfile> </activeProfiles> </settings>
Simple Project
This example describes the usage of the plugin on a standard simple, single-module Project
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <!-- CONF's --> <properties> <!--XRay Properties --> <!--IN PROFILE ~.m2/settings.xml--> <!--<xray.jiraURL></xray.jiraURL> <xray.resultsFormat></xray.resultsFormat> <xray.username></xray.username> <xray.password></xray.password>--> <xray.projectKey>MYPROJKEY</xray.projectKey> <!-- <xray.testExecKey></xray.testExecKey> <xray.testPlanKey></xray.testPlanKey> <xray.testEnvironments></xray.testEnvironments> <xray.fixVersion></xray.fixVersion> <xray.revision></xray.revision> --> <xray.surefire.location>${basedir}/target/surefire-reports</xray.surefire.location> <!--End Xray Properties --> </properties> <build> <pluginManagement> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.19.1</version> <configuration> <testFailureIgnore>true</testFailureIgnore> </configuration> </plugin> </plugins> </pluginManagement> </build> <reporting> <plugins> <plugin> <artifactId>maven-surefire-report-plugin</artifactId> </plugin> <plugin> <groupId>com.xpandit.xray</groupId> <artifactId>xray-maven-plugin</artifactId> <version>1.0.0</version> </plugin> </plugins> </reporting> <pluginRepositories> <pluginRepository> <id>xpand-plugins</id> <name>xpand-plugins</name> <url>http://maven.xpand-it.com/artifactory/releases</url> </pluginRepository> </pluginRepositories> </project>
Multi-Module Project
This example describes the usage of the plugin on a Module Project, in this case just one sub-module.
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <!-- CONF's --> <modules> <module>ModuleA</module> </modules> <properties> <!--XRay Properties --> <!--IN PROFILE ~/.m2/settings.xml--> <!--<xray.jiraURL></xray.jiraURL> <xray.resultsFormat></xray.resultsFormat> <xray.username></xray.username> <xray.password></xray.password>--> <xray.projectKey>MYPROJKEY</xray.projectKey> <!-- <xray.testExecKey></xray.testExecKey> <xray.testPlanKey></xray.testPlanKey> <xray.testEnvironments></xray.testEnvironments> <xray.fixVersion></xray.fixVersion> <xray.revision></xray.revision> --> <xray.surefire.location>${basedir}/target/surefire-reports</xray.surefire.location> <!--End Xray Properties --> </properties> <build> <pluginManagement> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.19.1</version> <configuration> <testFailureIgnore>true</testFailureIgnore> </configuration> </plugin> </plugins> </pluginManagement> </build> <reporting> <plugins> <plugin> <artifactId>maven-surefire-report-plugin</artifactId> </plugin> <plugin> <groupId>com.xpandit.xray</groupId> <artifactId>xray-maven-plugin</artifactId> <version>1.0.0</version> </plugin> </plugins> </reporting> <pluginRepositories> <pluginRepository> <id>xpand-plugins</id> <name>xpand-plugins</name> <url>http://maven.xpand-it.com/artifactory/releases</url> </pluginRepository> </pluginRepositories> </project>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <!-- CONF's --> <name>Module A</name> <properties> <!--XRay Properties --> <xray.surefire.location>${basedir}/target/surefire-reports</xray.surefire.location> <!--End Xray Properties --> </properties> </project>
Troubleshooting
Unable to upload the results file: The process is failing with status code 403
The importing of the execution results file failed and when you check the log, it shows the following:
By default, when you successively try to log into Jira with the wrong credentials, the Jira instance will prompt you to provide a CAPTCHA the next time you try to log in. It is not possible to provide this information via the Maven project configuration, so it will fail with status code 403 Forbidden.
You will need to log into Jira via the browser and provide the CAPTCHA.
If you are a Jira administrator, you can go to Jira administration > User Management and reset the failed login.
Version History
- 1.0.0 - 9 May 2016
- Import JUnit results: You can import the JUnit results to Xray either as an XML file or a folder with multiple XML files.
- Import JUnit results: You can import the JUnit results to Xray either as an XML file or a folder with multiple XML files.