Hey,
I'm running playwright tests on jenkins and I want to upload the test results to Jira using Xray.
I currently have a junit xml file with the test results that is generated by playwright, and I can already import it to Jira using xray-connector plugin for jenkins.
My problem is that I want to link the created test execution to an existing test plan using the testPlanKey as described in https://docs.getxray.app/display/XRAYCLOUD/Using+Xray+JSON+format+to+import+execution+results#UsingXrayJSONformattoimportexecutionresults-%22info%22object-TestExecutionissue
My current code without the test plan attempts is:
step([
$class: 'XrayImportBuilder',
endpointName: '/junit/multipart',
importFilePath: '*.xml',
importToSameExecution: 'true',
projectKey: 'APRV',
serverInstance: 'myserverinstance'
importInParallel: 'true',
inputInfoSwitcher: 'fileContent',
inputTestInfoSwitcher: 'fileContent',
importInfo: '''{
"fields": {
"project": {
"key": "projectkey"
},
"summary": "testing xray import",
"customfield_16800":{
"value": "customvalue"
}
},
}''',
testImportInfo: '''{
"fields": {
"project": {
"key": "projectkey"
},
"customfield_16800":{
"value": "customvalue"
}
}
}'''
])
I tried adding:
"xrayFields": {
"testPlanKey": "testplankey"
}
and
"testPlanKey": "testplankey"
to the importInfo JSON, the first attempt didn't throw an error but did not add the test plan to the execution after creating it, the second returned an error:
Error when executing always post condition: hudson.AbortException: Unable to confirm Result of the upload..... Upload Failed! Status:400 Response:{"error":"testPlanKey: testPlanKey"} at com.xpandit.plugins.xrayjenkins.task.XrayImportBuilder.tryUploadResults(XrayImportBuilder.java:828) at com.xpandit.plugins.xrayjenkins.task.XrayImportBuilder.uploadResults(XrayImportBuilder.java:699) at com.xpandit.plugins.xrayjenkins.task.XrayImportBuilder.importResultsSequential(XrayImportBuilder.java:600) at com.xpandit.plugins.xrayjenkins.task.XrayImportBuilder.perform(XrayImportBuilder.java:571) at jenkins.tasks.SimpleBuildStep.perform(SimpleBuildStep.java:123) at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:100) at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:70) at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47) at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang.Thread.run(Thread.java:829)
I'm basing my attempts on various Xray documentations, all for Jira cloud and the relevant version, but nothing I do seems to work, maybe I can get the help I need here? :)
Hi @Gal Yaniv — welcome to the community,
up front I have to say I‘m not proficient with jenkins-connector only communicatingto xray via API.
Aa far as I know and understand the link you sent it‘s not a combination of xml and json. For some frameworks as there is no valid result file one could create the json template as described in the link and then import the results via this file.
Best
Stefan
Hey @Stefan Salzl
Thanks for the quick answer! I think that the link I shared yesterday does not represent what I am doing, sorry for the misleading link,
The following link shows the use of the XrayImportBuilder class with it's parameters and JSON parameters, which is what I'm actually trying to do.
It does state that "testPlanKey" parameter would not be used in case you're using a multipart endpoint name, which is what I'm doing, therefore I'm resolving to using the JSON parameter for it, which does not work.
what workarounds are possible for adding the test plan to the execution?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Gal Yaniv
I could only refer to xray API. It provides possibility to add test executions to testplan (see following link):
https://docs.getxray.app/display/XRAY/Test+Plans+-+REST
Maybe this is a feasible workaround after importing results to a test execution.
Best
Stefan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Gal Yaniv ,
Hope you are doing well. Please let me know if this was helpful and in case your question is answered please hit the accept button to mark this as solved and make it easier for other users to find the right answers to similar questions.
Thx in advance.
Best
Stefan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello all,
I am facing the same issue in my jenkins pipeline using XrayImportBuilder. My final step is not working if I try to use iimportInfo :
importInfo: '''{
"fields": {
"labels": [
"bugfix",
"blitz_test"
]
}
}'''
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Cláudia Sofia Martins da Silva and welcome to the community,
Please appologize but I´m not familiar with different Jenkins based solutions. Could you describe what this is for? What does this solution? Does it communicate with the XRAY Rest API? what does "not working" mean? any error?
Best
Stefan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Stefan Salzl ,
Thank you very much for your answer. xray-connector is a plugin for Jenkins, that allows Jenkins to integrate an XML with Jira/Xray :
https://www.jenkins.io/doc/pipeline/steps/xray-connector/
In my pipeline I have a step in which I integrate an XML test report with Jira/Xray.
This XML is successfully integrated, and creates a Jira Test Execution, but unfortunately no labels are associated to this Test Execution.
step([$class: 'XrayImportBuilder',
//endpointName: '/nunit/multipart',
//endpointName: '/junit/multipart',
endpointName: '/junit',
importFilePath: '*/reports/*.xml',
projectKey: 'P34AMA',
importToSameExecution: 'false',
//testExecKey: 'TSTLKS-753',
serverInstance: '3146a388-d399-4e55-ae28-8c65404d6f9d',
credentialId:'55287529-194d-4e91-9964-7d740d8d2f61',
fixVersion: 'MSE 3.3',
inputInfoSwitcher: 'fileContent',
inputTestInfoSwitcher: 'fileContent',
testImportInfo: '''{
"fields": {
"labels": ["Quotes"],
}}'''
])
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi @Cláudia Sofia Martins da Silva
according to the documentation I can‘t see any information that fields could be set via
testImportInfo: '''{
"fields": {}
The documentation says this parameter expects a string (even not saying what this parameter would set).
Any further information where this is described/that it is possible?
Furthermore I guess this plugin will then also call the rest api. As the xray api can handle xray specific tasks I can‘t imagine this is possible at all as setting a field is a Jira native action and would need to call the Jira Rest API as well.
Best
Stefan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.