Versions Compared

Key

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

...

Since version 2.2.0, the Xray plugin will now set some build enviroment variables according to the operation result after each of the Xray Steps mensioned above.


Build Enviroment Variable NameMeaning and Value

XRAY_IS_REQUEST_SUCCESSFUL

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

XRAY_ISSUES_MODIFIED

All Issue keys that were modified and/or created by the step, seperated 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, seperated by ';'.

XRAY_TEST_EXECS

All Test Execution Issue keys that were modified and/or created by the step, seperated 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, seperated 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.

Info
titlePipeline Project Limitations

Due to Jenkins limitations, these variables will not be set on Pipeline projects.

...

Code Block
languagegroovy
titleJenkinsfile example (declarative)
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'])
            }
        }
    }
}

JUnit multipart

This is a declarative example, for JUnit based tests using the multipart variant/endpoint which allows customization over the Test Execution issue fields.

By changing the value of the endpointName variable, you can easily adapt it for other automation frameworks (e.g. Robot framework, TestNG, NUnit).  

Code Block
languagegroovy
titleJenkinsfile example (declarative)
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/multipart', importFilePath: 'java-junit-calc/target/surefire-reports/TEST-com.xpand.java.CalcTest.xml', importInfo: '''{
           "fields": {
              "project": {
                 "key": "CALC"
              },
              "summary": "Test Execution for java junit ${BUILD_NUMBER}",
              "issuetype": {
                 "id": "9"
              },
              "customfield_11807": [
                 "CALC-1200"
              ]
           }
        }''', inputInfoSwitcher: 'fileContent', serverInstance: '552d0cb6-6f8d-48ba-bbad-50e94f39b722'])
            }
        }

    }
}

Cucumber ("standard" workflow)

...