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

Compare with Current View Page History

« Previous Version 4 Next »

 

Overview

This add-on enables an easy integration between Jenkins and Xray for JIRA, providing the means for successful Continuous Integration by allowing users to report automated testing results.

 

Learn more

Please take a look at the general guidelines for Working with automated Tests and also the specifics for Testing with Cucumber.

 

Release Notes

Installation

The installation is made manually. For more information on how to install add-ons, please refer to how to install add-ons.

 

Requirements

This add-on was tested against Jenkins v2.32.x and it may not work properly with previous versions 


Manual Installation

If you have the add-on file (a file with extension .hpi), in order to manually install Xray for JIRA Jenkins Plugin, you need to perform the following steps:

  1. Go to the Update Center of Jenkins ("Manage Jenkins" > "Manage Plugins");
  2. Select the advanced tab;
  3. On the Upload Plugin section, click upload and select the file xray-for-jira-connector.hpi file.


Download the latest version of the Jenkins Plugin

You may download the latest version of the Jenkins plugin here: xray-for-jira-connector.hpi.


Configuration

Xray for JIRA Jenkins Plugin is configured in the global settings configuration page  Manage Jenkins > Configure System > Xray for JIRA configuration.

JIRA servers

The JIRA servers configuration defines connections with JIRA instances. 

To add a new JIRA instance connection, some properties need to be specified:

  1. Configuration alias;
  2. Server Address: The address of the JIRA Server where Xray is running;
  3. Authentication:
    1. User: Username;
    2. Password.

Creating a new Project

The project is where the work that should be performed by Jenkis is configured.

For this add-on you should configure a "Freestyle project". In the home page, start by clicking on the option "New Item", then select "Freestyle project", provide it a name and then click "OK".

Build Steps

Build steps are the building blocks of the build process. These need to be defined in the project configuration.

The add-on provides one build step for exporting Cucumber Scenario/Scenario Outlines from JIRA as .feature files, and one post-build action which publishes the execution results back to JIRA, regardless of the build process status.

 

Please note

The fields of the tasks may take advantage of Jenkins Environment variables, which can be used to populate fields such as the "Revision" for specifying the source code's revision. For more information, please see: Jenkins set environment variables.

Xray: Cucumber Features Export Task

By using this build step, it will export the Cucumber Tests (i.e. Scenario/Scenario Outlines) in .feature or bundled in a .zip file. The rules for exporting are defined here.

This build step corresponds to invoke Xray's Export Cucumber Tests REST API endpoint (more info here).

Configuration fields

Some fields need to be configured in order to export the Cucumber Tests.

fielddescription
JIRA instanceThe JIRA instance where Xray is running
Issue keysSet of issue keys separated by ";"

Filter ID

A number that indicates the filter id
File path

The relative path of the directory where the features should be exported to; normaly this corresponds to the "features" folder of the cucumber project that has the implement steps.

Note: the directory will be created if it does not exist.


Xray: Results Import Task

The add-on provides easy access to Xray's Import Execution Results REST API endpoints (more info here), and therefore it mimics the endpoints input parameters.

It supports importing results in Xray's own JSON format, Cucumber, Behave, JUnit, Nunit, among others.

Configuration fields

fielddescription
JIRA instanceThe JIRA instance where Xray is running
FormatA list of test result formats and it's specific endpoint
Execution Report File

The results relative file path

Note: regex is not supported.

Additional fields

Depending on the choosen test result format and endpoint, some additional fields may need to be configured.

format and specific endpointfielddescription

Behave JSON multipart

Cucumber JSON multipart

NUnit XML multipart

JUnit XML multipart

Robot XML multipart

Test execution fields

An object (JSON) specifying the fields for the issue. You may either specify the object, directly in the field, or the file path.



Learn more

The custom field IDs can be discovered using the JIRA REST API Browser tool included in JIRA. Each ID is of the form "customfield_ID".

Another option, which does not require JIRA administration rights, can be invoking the "Get edit issue meta" in an existing issue (e.g. in a Test issue) as mentioned here.

Ex: GET http://yourserver/rest/api/2/issue/CALC-1/editmeta 

 

NUnit XML

JUnit XML

Robot XML

Project keyKey of the project where the Test Execution (if the Test Execution Key field wasn't provided) and the Tests (if they aren't created yet) are going to be created
Test execution key

Key of the Test Execution

Test plan keyKey of the Test Plan
Test environmentsList of Test Environments separated by ";"
RevisionSource code's revision being target by the Test Execution
Fix versionThe Fix Version associated with the test execution (it supports only one value)


Examples

Cucumber

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.

For this scenario, the Jenkins project would be configured with a set of tasks responsible for:

  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.

Finished all configurations, hit the save button in 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 JIRA Jenkins Plugin provides an option for users who want to create new Test Executions and have control over newly created Test Execution fields. The way it provides this is by allowing the user to send two files, the normal execution result file and a JSON 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 Cucumber JSON Multipart format. When selecting this option you can, additionally, configure the Test Execution fields in two ways:

  • Inserting the relative path to the JSON file containing the information;
  • Or by inserting 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

Finished all configurations, hit the save button in 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.

JUnit

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

In a scenario where the user wants to import JUnit XML reports, a typical Job outline would be:

  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 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 format JUnit XML is chosen.

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

Troubleshooting

The build process is failing with status code 403

Your build process is failing and when you check its 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 the build process, 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.

 

  • No labels