Page History
...
It invokes Xray's Import Cumcumber Tests REST API endpoint (see more information here)
field | decription |
---|---|
JIRA instance | The Jira instance where Xray is running. |
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. |
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. |
...
format and specific endpoint | field | description | |||||
---|---|---|---|---|---|---|---|
Behave JSON multipart Cucumber JSON multipart NUnit XML multipart JUnit XML multipart Robot XML multipart TestNG XML multipart | 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.
| |||||
NUnit XML JUnit XML Robot XML TestNG XML | Import to Same Test Execution | When this option is check, if you are importing multiple execution report files using a glob expression, the results will be imported to the same Test Execution | |||||
Project key | Key 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 key | Key of the Test Plan | ||||||
Test environments | List of Test Environments separated by ";" | ||||||
Revision | Source code's revision being target by the Test Execution | ||||||
Fix version | The Fix Version associated with the test execution (it supports only one value) |
...
Code Block | ||||
---|---|---|---|---|
| ||||
pipeline { agent any stages { stage('Export Cucumber') { steps { step([$class: 'XrayExportBuilder', filePath: '\\features', issues: 'IF-1', serverInstance: '2ffc3a3e-9e2f-4279-abcd-e9301fe47bed']) } } } } |
Examples
...
Info | ||
---|---|---|
| ||
For Pipeline specific documentation, you may want to give a look at: |
Examples
JUnit
This is a declarative example, for JUnit based tests.
Code Block | ||||
---|---|---|---|---|
| ||||
pipeline {
agent any
stages {
stage('Compile'){
steps {
checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'SparseCheckoutPaths', sparseCheckoutPaths: [[path: 'java-junit-calc/']]]], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'a3285253-a867-4ea7-a843-da349fd36490', url: 'ssh://git@localhost/home/git/repos/automation-samples.git']]])
sh "mvn clean compile -f java-junit-calc/pom.xml"
}
}
stage('Test'){
steps{
sh "mvn test -f java-junit-calc/pom.xml"
}
}
stage('Import results to Xray') {
steps {
step([$class: 'XrayImportBuilder', endpointName: '/junit', fixVersion: 'v3.0', importFilePath: 'java-junit-calc/target/surefire-reports/*.xml', importToSameExecution: 'true', projectKey: 'CALC', serverInstance: '552d0cb6-6f8d-48ba-bbad-50e94f39b722'])
}
}
}
} |
Cucumber ("standard" workflow)
This is a declarative example, for JUnit based testsCucumber tests using the "standard" workflow (see Testing with Cucumber).
Code Block | ||||
---|---|---|---|---|
| ||||
pipeline { agent any stages { stage('CompileExport features from Xray'){ steps { checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'SparseCheckoutPaths', sparseCheckoutPaths: [[path: 'java-junit-calc/']]]], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'a3285253-a867-4ea7-a843-da349fd36490', url: 'ssh://git@localhost/home/git/repos/automation-samples.git']]]) step([$class: 'XrayExportBuilder', sh "mvn clean compile -f java-junit-calc/pom.xml"filePath: 'cucumber_xray_tests/features', filter: '11400', serverInstance: '552d0cb6-6f8d-48ba-bbad-50e94f39b722']) } } stage('Test'){ steps{ sh "mvn test "cd cucumber_xray_tests && cucumber -x -f json java-junit-calc/pom.xml-o data.json" } } stage('Import results to Xray') { steps { step([$class: 'XrayImportBuilder', endpointName: '/junitcucumber', fixVersion: 'v3.0', importFilePath: 'java-junit-calc/target/surefire-reports/*.xml', importToSameExecution: 'true', projectKey: 'CALC', cucumber_xray_tests/data.json', serverInstance: '552d0cb6-6f8d-48ba-bbad-50e94f39b722']) } } } } |
Cucumber (
...
"VCS/Git based" workflow)
This is a declarative example, for Cucumber tests using the "standardVCS/Git based" workflow (see see Testing with Cucumber).
Code Block | ||||
---|---|---|---|---|
| ||||
pipeline { agent any stages { stage('Export features fromSynch (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: 'XrayExportBuilderXrayImportFeatureBuilder', filePathfolderPath: 'cucumber_xray_tests/features', lastModified: '10', filterprojectKey: '11400CALC', serverInstance: '552d0cb6-6f8d-48ba-bbad-50e94f39b722']) } } stage('Test'){ steps{ Export features from Xray'){ sh "cd cucumber_xray_tests && cucumber -x -f json -o data.json" 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']]]) stage('Import results to Xray') { sh "rm steps {-rf cucumber_xray_tests/features" step([$class: 'XrayImportBuilderXrayExportBuilder', endpointNamefilePath: 'cucumber_xray_tests/cucumberfeatures', importFilePathfilter: 'cucumber_xray_tests/data.json11400', serverInstance: '552d0cb6-6f8d-48ba-bbad-50e94f39b722']) } } } } |
Cucumber ("VCS/Git based") worflow)
This is a declarative example, for Cucumber tests using the "VCS/Git based" workflow (see Testing with Cucumber).
Code Block | ||||
---|---|---|---|---|
| ||||
pipeline stage('Test'){ steps{ agent any stages { sh "cd cucumber_xray_tests && cucumber -x -f json -o data.json" stage('Synch (update) recent tests to Xray'){} steps {} checkoutstage([$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']]])'Import results to Xray') { steps { step([$class: 'XrayImportBuilder', endpointName: 'XrayImportFeatureBuilder/cucumber', folderPathimportFilePath: 'cucumber_xray_tests/featuresdata.json', lastModified: '10', projectKey: 'CALC', serverInstance: '552d0cb6-6f8d-48ba-bbad-50e94f39b722']) } } } } |
Using parameters
You can ask for human input in your pipeline builds by passing parameters
Code Block | ||||
---|---|---|---|---|
| ||||
pipelinestage('Export features from Xray'){ agent any parameters 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']]]string(defaultValue: "NTP", description: '', name: 'projectKey') string(defaultValue: "Android", description: '', name: 'env') } sh "rm -rf cucumber_xray_tests/features"stages { stage ('Import Results') { step([$class: 'XrayExportBuilder', filePath: 'cucumber_xray_tests/features', filter: '11400', serverInstance: '552d0cb6-6f8d-48ba-bbad-50e94f39b722']) steps { } }step([$class: 'XrayImportBuilder', stage('Test'){ endpointName: '/junit', steps{ importFilePath: 'java-junit-calc/target/surefire-reports/*.xml', sh "cd cucumber_xray_tests && cucumber -x -f json -o data.json" importToSameExecution: 'true', projectKey: params.projectKey, } } revision: params.projectKey + env.BUILD_NUMBER, stage('Import results to Xray') { serverInstance: '552d0cb6-6f8d-48ba-bbad-50e94f39b722', steps { testEnvironments: params.env]) step([$class: 'XrayImportBuilder', endpointName: '/cucumber', importFilePath: 'cucumber_xray_tests/data.json', serverInstance: '552d0cb6-6f8d-48ba-bbad-50e94f39b722']) } } } } } |
Recommendations
You can automatically generate your step scripts using the Jenkins Snippet Generator.
...
This is the simplest way to generate your step script, and we strongly recommend the use of this snippet due to the complexity of the Xray: Results Import Task some task related parameters.
Troubleshooting
...