Page History
...
- Configuration alias
- Hosting: Hosting (instance type) in this case Server/Data CenterCloud.
- Server Address: The address of the Jira Server where Xray is running
- Credentials:
- Use the Jenkins Credentials Plugin to set the API key/secret (please check Global Settings: API Keys for more info on creating API keys)
- Make sure that 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.
- 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 a User scoped credential in the build task.
To add a new Credential:
Xray Client ID should be placed in the Username field
Xray Client Secret should be placed in the Password field
Note: the Configuration ID is not editable. This value can be used in the pipeline scripts.
...
It invokes Xray's Export Cucumber Tests REST API endpoint (see more information here).
Configuration
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.
...
This build step will import existing cucumber Tests from existing Cucumber feature files into Xray issues. This Task will import from .feature files and also from .zip files.
It invokes Xray's Import Cumcumber Cucumber Tests REST API endpoint (see more information here)
field | decriptiondescription |
---|---|
Jira instance | The Jira instance where Xray is running. |
Credentials | If the above Jira Instance does not have any credential configured, you must define an User scoped credential here |
Project Key | This is the project where the Tests and Pre-Conditions will be created/updated. |
Cucumber feature files directory | This 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 hours | By entering an integer n here, only files that where 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.
...
Since version 2.2.0, the Xray plugin will now set some build environment variables according to the operation result after each of the Xray Steps mentioned above.
Build Enviroment Environment Variable Name | Meaning 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 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 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. |
...
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.
...
Expand | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
...
Expand | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||||||||||||||
|
...
This is a declarative example, for Cucumber tests using the "VCS/Git based" workflow (see Testing in BDD with Gherkin based frameworks (e.g. Cucumber)).
Code Block | ||||
---|---|---|---|---|
| ||||
pipeline { agent any stages { stage('Synch (update) recent tests to Xray'){ steps { checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'a3285253-a867-4ea7-a843-da349fd36490', url: 'ssh://git@localhost/home/git/repos/automation-samples.git']]]) step([$class: 'XrayImportFeatureBuilder', folderPath: 'cucumber_xray_tests/features', lastModified: '10', projectKey: 'CALC', serverInstance: '552d0cb6-6f8d-48ba-bbad-50e94f39b722']) } } stage('Export features from Xray'){ steps { checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'a3285253-a867-4ea7-a843-da349fd36490', url: 'ssh://git@localhost/home/git/repos/automation-samples.git']]]) sh "rm -rf cucumber_xray_tests/features" step([$class: 'XrayExportBuilder', filePath: 'cucumber_xray_tests/features', filter: '11400', serverInstance: '552d0cb6-6f8d-48ba-bbad-50e94f39b722']) } } stage('Test'){ steps{ sh "cd cucumber_xray_tests && cucumber -x -f json -o data.json" } } stage('Import results to Xray') { steps { step([$class: 'XrayImportBuilder', endpointName: '/cucumber', importFilePath: 'cucumber_xray_tests/data.json', serverInstance: '552d0cb6-6f8d-48ba-bbad-50e94f39b722']) } } } } |
...
Jira instances configuration via Groovy script (Jenkins Script Console)
If you use a containerized containerised version of Jenkins, or simply want to avoid creating the Jira configurations manually (using the Jenkins UI), you can use the following script in the Jenkins Script Console.
...