0

I have added the XrayImportBuilder to my pipeline script to import JUnit test results to Xray in Jira. It actually works fine and it creates Test issues and Test Executions issues as expected.

However, the json defined in importInfo just sets the parameters for the Test Execution issue in Jira. It does not affect the information for the Test issue:

step([$class: 'XrayImportBuilder', 
   endpointName: '/junit/multipart', 
   testPlanKey: 'CL-25466', 
   importFilePath: '**/target/surefire-reports/**/*.xml',
   importInfo: '''{
     "fields": {
       "project": {
          "key": "CL"
       },
       "components": [{
          "name": "123"
       }],
       "summary": "Test Execution for java junit"
    }
   }''',
importToSameExecution: 'true',
inputInfoSwitcher: 'fileContent',
serverInstance: '123435567678123435567678123435567678'])

Is there a way to add additional field information for the Test issue, except for the standard ones like testPlanKey, fixVersion..)? I already checked the documentation for XrayImportBuilder (https://www.jenkins.io/doc/pipeline/steps/xray-connector/), but it is not well described what the parameters do in detail.

Jake2Finn
  • 516
  • 5
  • 19

1 Answers1

1

The "importInfo" object is used to define fields the Test Execution issue. The "testImportInfo" object, which is something quite new, is used to define fields for the Test issues. Both objects use the syntax of Jira's REST API for updating fields, making use of a "fields" JSON object as you mentioned.

Note: thanks for the feedback on that documentation; I'll see if we can clarify it in a next version.

Sérgio
  • 1,777
  • 2
  • 10
  • 12
  • Thanks for the info! I just tried it out with the following code: testImportInfo: '''{"fields": {"project": {"key": "CL"}, "components": [{"name": "123"}], "summary": "Test for java junit", "customfield_11600": "/123/JUnit"}}''', but the export now fails giving me no error or exception. It just fails. I am using plugin version 2.4.0, so I assume the object testImportInfo is supported. Is there anything I need to know when I use this object? – Jake2Finn Mar 05 '21 at 13:17
  • Are you using Xray cloud or server? If using Jira server, which Xray version do you have? On Xray server this is available in v3.5.0. If you don't have logs it will be hard to diagnose. What does it say on the console logs in Jenkins? can you share a screenshot? Otherwise, you may need to debug the request that goes to Jira or look at it from Jira side/logs. – Sérgio Mar 05 '21 at 15:28
  • I just got confirmed it is actually 4.2.8 Data center. That should work, shouldnt it? – Jake2Finn Mar 05 '21 at 16:44
  • I was able to figure out the following: java.lang.NullPointerException at com.xpandit.plugins.xrayjenkins.task.XrayImportBuilder.tryUploadResults(XrayImportBuilder.java:789) at com.xpandit.plugins.xrayjenkins.task.XrayImportBuilder.uploadResults(XrayImportBuilder.java:693) at com.xpandit.plugins.xrayjenkins.task.XrayImportBuilder.importResultsSequential(XrayImportBuilder.java:594) at com.xpandit.plugins.xrayjenkins.task.XrayImportBuilder.perform(XrayImportBuilder.java:565) – Jake2Finn Mar 05 '21 at 17:19
  • okay I figured it out myself by checking the class XrayImportBuilder .java:789 on gitHub: I was missing inputTestInfoSwitcher... now it works! :) – Jake2Finn Mar 05 '21 at 17:32
  • awesome @Jake2Finn :) – Sérgio Mar 05 '21 at 18:07
  • @Jake2Finn, can you please update your REST request with how you used `testImportInfo`? thanks! – Leonardo Mar 19 '21 at 15:14