You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

In order to make the integration in your Java Maven projects and Xray easier we have developed the Xray-Maven-Plugin. This plugin 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 Xray for JIRA instance.

List of Available Properties

The table bellow describes all the properties available on the plugin. 

Property NameRequired ((tick)-Yes,(question)-Optional)DescriptionExamples
xray.jiraURL
(tick)Full URL of JIRA, including the relative path if its being used
http://localhost:8080
xray.resultsFormat
(tick)

Results format. Available formats here

case sensitive

JUNIT
xray.username
(tick)Jira Username
admin
xray.password
(tick)

JIRA Password

plain-text only

password
xray.projectKey
(tick)JIRA Project Key MYPROJKEY
xray.testExecKey
(question)Test Execution Issue IDMYT2-5
xray.testPlanKey
(question)Test Plan Issue IDMYT2-54
xray.testEnvironments
(question)Test EnvironmentiOS 
xray.fixVersion
(question)Fix VersionRelease 1.0
xray.revision
(question)Revision1234
xray.surefire.location
(tick)Folder with files .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 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
JUNITJUnit XML output format, more information regarding it's 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 

~/.m2/settings.xml
<?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>

    <repositories>
		<!-- OTHER REPOS -->
        <repository>
            <id>xpandit</id>
            <name>xpand-releases</name>
            <url>http://maven.xpand-it.com/artifactory/releases</url>
        </repository>
    </repositories>
</project>

Muti-Module Project

This example describes the usage of the plugin on a Module Project, in this case just one sub-module

pom.xml
<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>

    <repositories>
		<!-- OTHER REPOS -->
        <repository>
            <id>xpandit</id>
            <name>xpand-releases</name>
            <url>http://maven.xpand-it.com/artifactory/releases</url>
        </repository>
    </repositories>
</project>
ModuleA.pom
<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 is failing and when you check the log, it presents you the following:

By default, when the user successively tries to log in to JIRA with wrong credentials, the next time you try to log in, JIRA instance will prompt you to provide a CAPTCHA. It is not possible to provide this information via maven project configuration, so it will fail with status code 403 Forbidden.

You will need to log in to JIRA via browser and provide the CAPTCHA.

In case you are a JIRA administrator, you can go to JIRA administration > User Management and reset the failed login for the user who failed to log in.


Version History

  • 1.0.0 - 9 May 2016
    • Import JUnit results: You can import the JUnit results to Xray for JIRA - Either a XML file or a folder with multiple XML files;

  • No labels