Xray for Jira automated tests with Jenkins

Following the segment initiated with Bamboo, in this article we will show you how you can automate your tests using Jenkins and our Xray for Jira.

In Xray, Automated Tests are executed by an external tool, which controls the test executions and the comparison of actual outcomes and the predicted ones. They can automate some repetitive tasks in a formalized testing process already in place, or add additional testing that would be difficult to perform manually.

As the testing tool, we will use Cucumber because it allows you to execute plain-text functional descriptions as automated tests. You can find more information about how automated tests are created in Xray, as well as more information about Cucumber, in Xray documentation and Cucumber’s website, respectively.

It is also important to point out that this is just possible since Xray makes also available it’s Rest API and, with that, we will be able to export Test definitions and import execution results.

Xray for JIRA add-on for Jenkins aims to simplify the process of continuous integration. With the setup of some Xray specific tasks, users can now easily export Cucumber features, report automated testing results for many different automated testing frameworks and associate them with new or existing Tests, Test Executions, Test Plans, Test Environments, and more.


Let’s get to know the add-on by running two examples. For each example we will create two plans, both taking into account the specific testing framework and with the common final goal of importing the execution results to a specific Xray endpoint.

We will assume that you already know how to pull your test project from your repository and how to run the tests in the Continuous Integration environment. As such we will only focus on how to configure the Xray specific tasks.


Apart from supporting Cucumber natively, Xray enables you to take advantage of many other testing frameworks like JUnit. In this sense, Xray for Jenkins lets you import results in other formats besides Cucumber JSON.

  1. Pulling the JUnit project;
  2. Executing the tests in the CI environment;
  3. Importing the execution results, including Tests, to Jira.

Importing the execution results to Jira

To start the configuration, add the post-build action Xray: Results Import Task.


After that, configure it.

In this example, we have a configuration where the JUnit XML format is chosen.


After running the plan, the expected result is a new Test Execution issue created in the Jira instance.



In a typical Cucumber Workflow, after having created a Cucumber project and the Cucumber tests specified in Jira, you may want to have a project that exports the features from Jira, executes the automated tests on a CI environment and then imports back its results.

  1. Pulling the Cucumber project;
  2. Exporting Cucumber features from Jira to your Cucumber project;
  3. Executing the tests in the CI environment;
  4. Importing the execution results back to Jira.

Exporting Cucumber features

To start the configuration, add the build step Xray: Cucumber Features Export Task.


After that, configure it.

In this example, we configured the task to extract the features from a set of issues (PROJ-78 and PROJ-79) to the folder that holds the Cucumber project.


Importing the execution results

To start the configuration, add the post-build action Xray: Results Import Task.


After that, configure it.

In this example, we configured the task to import the Cucumber JSON results back to Jira.


Once all configurations are done, click Save at the bottom of the page.

After running the job, the expected result is a new Test Execution issue created in the Jira instance.


Importing the execution results with user-defined field values

For Cucumber, Behave, JUnit, Nunit and Robot, Xray for Jenkins allows you to create new Test Executions and have control over newly-created Test Execution fields. You can send two files, the normal execution result file and a JSON file similar to the one Jira uses to create new issues. More details regarding how Jira creates new issues here.

For this scenario and example, the import task needs to be configured with the Cucumber JSON Multipart format. When selecting this option, you can additionally configure the Test Execution fields in one of two ways:

  • Insert the relative path to the JSON file containing the information, or
  • Insert the JSON content directly in the field.

In this example, we configured the following object:
"fields": {
"project": {
"key": "PROJ"
"summary": "Test Execution for Cucumber results (Generated by job: ${BUILD_TAG})",
"issuetype": {
"id": "10102"

And configured the task to import the Cucumber JSON Multipart results back to Jira.


Once all configurations are done, click Save at the bottom of the page.

After running the job, the expected result is a new Test Execution issue created in the Jira instance, with the Test Execution fields as specified in the Jenkins build step configuration.


In sum…

Importing automated execution results and exporting Cucumber features is now easier with Xray for Jira add-on for Jenkins. With some simple parametrization, you can take advantage of the Xray’s REST API and every available endpoint for importing results, to “Continuously Integrate” and thus continuously improve your product quality, while having on-time feedback that will help you promptly fix any issue.

Good luck in “Continuous Integrating” your Tests!

Editor’s Note: This post was originally published in August 2016 and has been completely revamped and updated for accuracy and comprehensiveness in 2018.



  • Hi,

    I have integrated xray with jenkins. That works fine. But xray create always new test executions. We have a lot test executions result. Can xray update a test executions instead of create new test execution?

    Best regards

    Tien Hanh Pham

  • Hi,

    How to import multiple JUnit test execution results using XRay Jenkins plugin? (JUnit result file names are generated randomly)


  • Hi everybody,

    as a newbie I would like to now where I can find the Jenkins plugin for XRAY?

    I now that the plugin is named like “xray-for-jira-connector.hpi”.

    Thank you for any answeres

    Best regards,

  • Hi ,

    What ID value should be passed in JSON for execution type ?how can I get this ID?
    I am configuring the JUNIT results in Jenkins with XRAY using JUNIT xml multipart import format .

    I want to Xray to create the execution issue each tyime when the Jenkins completes the build with name given by me in JSON

    ERROR: Step ‘Xray: Results Import Task’ failed: Unable to confirm Result of the upload….. Upload Failed! Status:400 Response:issuetype: issue type is required

    Thanks in advance

    • Hi Mangala,
      Thank you for your comment!

      To get the ID’s place the mouse point over the Edit option of the Issue Type and you may find the ID in the URL.
      You are getting the error because the issue type must be send in the Json data file.

      If you still need any assistance please open a ticket with this question here?
      Our technical team will be glad to help you.

      Best regards,
      Xray Team

  • Hi,
    I integrated Xray with Jenkins.
    Type of my test results is JUnit XML.
    I can send to Xray JUnit XML reports.
    But I don’t see anything about JUnit XML output at Xray.

    Thank you for any answeres
    Best regards.

  • Hello,
    We integrated Xray with Jenkins.
    I would like to know how to adding the “Test Environment” to the test result imported to Jira?
    Thank you very much.
    Best Regards,

  • Great plugin. Been using it import existing feature files from SCM into XRay.
    Scenario level tags convert to labels in the issue but feature level tags are not imported. Is the intentional? Am I missing something?

    • Hi Steven,
      Thank you for your kind words. 😀
      Concerning importing of “features”, what Xray provides is an endpoint for importing Cucumber based “Scenario” / “Scenario Outline” and related “Background” as Tests and Pre-Conditions, respectively.
      The main purpose is to import tests and not the “Feature(s)” (i.e. requirements) themselves; it is assumed that those “Feature(s)” already exist and are already managed in Jira side, as user stories/epics or a similar issue type.
      You may see how the import process works in more detail here https://confluence.xpand-it.com/display/XRAY/Importing+Cucumber+Tests+-+REST
      The overall workflow assumes that someone wrote the user stories/features in Jira and that later on you will write tests (i.e. Cucumber Scenarios) in order to validate them.

      Best regards,
      Xray Team

  • We are getting an error message configuring the Jenkins plugin, after adding the configuration and clicking on ‘Test Connection’ we get { Could not establish connection }

  • When I use Jenkins to run an automated test case in Katalon which also exists in Jira with the same Xray key, Xray creates a new test.

  • Hello,
    I want to write Automation test cases and Manual test cases in the same XRAY TC task. but once I select Manual TC to Automation , Written manual test cases deleted and vice a versa.

    Please assist me to write Automation and MAnual test case together.

    Thanks in Advance!!

  • Hi
    I do an integration process with the XRAY tool for the CI process automatically
    Is there a way to link the steps in each test?
    That means XRAY will have the business steps and connect each step to the code lines in the automated script
    And at the end of the process an import to xray will be made and there every step is displayed whether passed or not


    • Hi Nizan,

      Please reach out to our support team on Service Desk .

      They’ll ask you some additional questions to best answer your request. 🙂

      Best regards,
      Team Xray

Leave a reply