Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Go to the Update Center of Jenkins in Manage Jenkins > Manage Plugins.
  2. Select the advanced Advanced tab
  3. In the Upload Plugin section, click upload and select the file xray-connector.hpi file.

...

Since version 2.1.0, you can install the plugin by using the Jenkins native Web UI. You can read more about how to to do it here.

Configuration

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

Credential permissions

If you want to ket your Jenkins' users to use their own Jira credentials in each build, you need to make sure that the users that need to configure the jobs have both USE ITEM and USE OWN permissions.

These permissions are not configurable in the Credentials plugin by default, you need to run your Jenkins instance with the following flags enabled:

-Dcom.cloudbees.plugins.credentials.UseOwnPermission=true -Dcom.cloudbees.plugins.credentials.UseItemPermission=true

After enabling these flags, go to the Credentials plugin configuration page, and give the required users the USE ITEM and USE OWN permissions.

You can read more about these permissions in the official CloudBees documentation.

Jira

...

Instance

The Jira servers configuration defines connections with Jira instances.

...

  1. Configuration alias
  2. Hosting: Hosting (instance type) in this case Server/Data Center.
  3. Server Address: The address of the Jira Server where Xray is running
  4. Credentials:
    1. Use the Jenkins Credentials Plugin to set the usernameAPI key/password (if you are using a Server/Data Center instance).secret (please check Global Settings: API Keys for more info on creating API keys)
    2. Make sure that the user you are using have was used to create the API key has the following permissions in the projects where you want to import the results and import/export feature files: View, Edit, Create.
    3. This field is optional - if you don't want to use a System scoped credential to authenticate in your instance, you can leave this field empty and force the users to use an a User scoped credential in the build task.

...

Note: the Configuration ID is not editable. This value can be used in the pipelines pipeline scripts.


Info
titlePlease note

The user present in this configuration must exist in the Jira instance and have permission to Create Test and Test Execution Issues

...

  • Freestyle projects
  • Maven Projects
  • Multi-configuration Projects
  • Pipeline Projects

In On the home page, clicking click for example New Item > Freestyle project, provide a name, and then click OK.

...

This build step 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.

It invokes Xray's Export Cucumber Tests REST API endpoint (see more information here).

...

Some fields need to be configured in order to export the Cucumber Tests. As input, you can either specify issue keys (see the endpoint documention documentation here) or the ID of the saved filter in Jira.

fielddescription
Jira instanceThe Jira instance where Xray is running
CredentialsIf the above Jira Instance does not have any credential configured, you must define an a User scoped credential here
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; normally, this corresponds to the "features" folder of the Cucumber project that has the implementation steps. Note: The directory will be created if it does not exist.

...

It invokes Xray's Import Cumcumber Tests REST API endpoint (see more information here)

fielddecriptiondescription
JIRA instanceThe Jira instance where Xray is running.
CredentialsIf the above Jira Instance does not have any credential configured, you must define an a User scoped credential here
Project KeyThis is the project where the Tests and Pre-Conditions will be created/updated.
Cucumber feature files directoryThis is the directory containing your feature files. All the files in this directory and sub directories will be imported. Supports both relative and absolute paths.
Modified in the last hoursBy entering an integer n here, only files that where were modified in the last n hours will be imported.
Leave empty if you do not want to use this parameter.

...

The app provides easy access to Xray's Import Execution Results REST API endpoints (see more information here). Therefore, it mimics the endpoints' input parameters.

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

...

fielddescription
Jira instanceThe Jira instance where Xray is running
CredentialsIf the above Jira Instance does not have any credential configured, you must define an a User scoped credential here
FormatA list of test result formats and its their specific endpoint
Execution Report File

The results' relative or absolute file path

Note: glob expressions are supported for

  • JUnit
  • JUnit Multipart
  • TestNG
  • TestNG Multipart
  • NUnit
  • NUnit Multipart
  • Robot framework
  • Robot framework Multipart

Additional fields

Depending on the chose chosen 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

TestNG XML multipart

Import to Same Test ExecutionWhen this option is checkchecked, if you are importing multiple execution report files using a glob expression, the results will be imported to the same Test Execution

Test execution fields

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



Info
titleLearn more

The custom field IDs can be obtained 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, is to invoke the "Get edit issue meta" in an existing issue (e.g., in a Test issue) as mentioned here.

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

Import in parallelIf there are several result files, when this checkbox is selected, we will import all the files in parallel (using all available CPU cores)


NUnit XML

JUnit XML

Robot XML

TestNG XML

Import to Same Test ExecutionWhen this option is checkchecked, if you are importing multiple execution report files using a glob expression, the results will be imported to the same Test Execution
Project keyKey of the project where the Test Execution (if the T est 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 targeted by the Test Execution
Fix versionThe Fix Version associated to associate with the test execution (it supports only one value)
Import in parallelIf there are several result files, when this checkbox is selected, we will import all the files in parallel (using all available CPU cores)

...

Build Environment Variable NameMeaning and Value

XRAY_IS_REQUEST_SUCCESSFUL

Contains the string 'true' if all requests made by the step were successful, or 'false' otherwise.

XRAY_ISSUES_MODIFIED

All Issue keys that were modified and/or created by the step, separated by ';' with no duplicated entries (E.g. 'CALC-100;CALC-101;CALC-102').

XRAY_RAW_RESPONSE

The unprocessed JSON response of all requests made by the step, separated by ';'.

XRAY_TEST_EXECS

All Test Execution Issue keys that were modified and/or created by the step, separated by ';' with no duplicated entries (E.g. 'CALC-200;CALC-201;CALC-202').

Please note that in same some cases, it will be not possible to determine the issue type of the Issue key returned in the request response and in that case, the key it will only be added to the XRAY_ISSUES_MODIFIED variable.

XRAY_TEST

All Test Issue keys that were modified and/or created by the step, separated by ';' with no duplicated entries (E.g. 'CALC-300;CALC-301;CALC-302').

Please note that in same some cases, it will be not possible to determine the issue type of the Issue key returned in the request response and in that case, the key it will only be added to the XRAY_ISSUES_MODIFIED variable.

...

In this example, we configured the task to import to the Project IF of the Xray instance all the .features and .zip files that are contained in \Cucumber directory and sub directoriessubdirectories, which were modified in the last 3 hours.

...

Xray for Jenkins provides support for pipelines pipeline projects, allowing you to use Xray-specific tasks.

~~~~~


There are 3 available steps to be used in a Pipeline project:

...

Info
titleGenerated syntax helper

For each of the steps mentioned above, you can check the generated syntax reference in the official Jenkins documentation website.

Note
iconfalse
titleSee and try some examples by yourself
typeInfo

Please see a tutorial with working Examples using Jenkins pipeline, showcasing different scenarios, which you can download and try by yourself.

Step: XrayImportBuilder (import test execution results)

...

Expand
titleParameters
ParameterRequired?TypeDescription
serverInstanceYesStringThe ID of the Jira instance configured in the Jenkins System Configuration
endpointNameYesString

The result file type to be imported. Allowed Values:

  • "" (Xray Json format)
  • "/multipart" (Xray JSON multipart format)
  • "/cucumber"
  • "/cucumber/multipart"
  • "/behave"
  • "/behave/multipart"
  • "/junit"
  • "/junit/multipart"
  • "/nunit"
  • "/nunit/multipart"
  • "/robot"
  • "/robot/multipart"
  • "/bundle" (import of zip file with several cucumber results)
  • "/testng"
  • "/testng/multipart"
  • "/xunit"
  • "/xunit/multipart"

Please note that not all endpoints are available for Jira Sever/Cloud. Please refer to the REST API documentation to see what is available in your instance.

projectKeyYesStringThe Jira project key where you want to import your results
importFilePathYesString

File path where the result files can be found.

credentialIdYes, if the Jira instance was configured without credentials in System ConfigurationStringCredential ID from the Credentials plugin to be used to authenticate the Jira requests
testEnvironmentsNoString

Test enviroments environments to be added to the Test Execution issue, seperated separated by ";".

(warning) This value will only be used if the endpointName is not multipart

testPlanKeyNoString

All Tests will be added to the given Test Plan key, if provided.

(warning) This value will only be used if the endpointName is not multipart

fixVersionNoString

Fix version to be added to the Test Execution issue.

(warning) This value will only be used if the endpointName is not multipart

testExecKeyNoString

Key of the test Exeution Execution issue to be updated. Leave empty to create a new issue with the import.

(warning) This value will only be used if the endpointName is not multipart

revisionNoString

Source code and documentation version used in the test execution.

(warning) This value will only be used if the endpointName is not multipart

importInfoYes, if multipart endpointStringFile path to the Test Execution info file OR JSON String with the info.
inputInfoSwitcherYes, if importInfo is being usedString

Allowed values:

  • "filePath" - if importInfo field is used and represents a file path
  • "fileContent" - if importInfo field is used and represents a JSON text
testImportInfoNoStringFile path to the Test info file.
inputTestInfoSwitcherYes, if testImportInfo is being usedString

Allowed values:

  • "filePath" - if testImportInfo field is used and represents a file path
  • "fileContent" - if testImportInfo field is used and represents a JSON text
importToSameExecutionNoString

Allowed values:

  • "true" - to import all created tests and linked them to a single Test Execution issue
  • "" - link a Test Execution issue to every imported Test issue
importInParallelNoString

Allowed values:

  • "true" - to import all result files (if there are multiple) in parallel, in order to speed up the import process
  • "" - to import all result files (if there are multiple) sequentially

...