0

when i try importing testng xml report to xray jira manualy/automation its throwing error

"Error importing Execution results Error creating tests in jira with following error

Project Name is required

{
    "error": "Error creating tests in Jira with the following error(s): Project Name is required."
}

https://xray.cloud.xpand-it.com/api/v2/import/execution/testng?projectKey=TM&testExecKey=TM-3563

due to this custom label report is not getting added

ERROR

Note-project name i have alreadry added in UI

JIRA ERROR

  • Can you please provide further details? 1) Are you using Xray on Jira Cloud or on Jira server/datacenter (on-premises)? 2) how are you submiting the results? Using the REST API directly? Can you provide the exact HTTP request you did? – Sérgio Apr 27 '21 at 09:09
  • { "error": "Error creating tests in Jira with the following error(s): Project Name is required." } https://xray.cloud.xpand-it.com/api/v2/import/execution/testng?projectKey=TM&testExecKey=TM-3563 – rahul mohanty Apr 27 '21 at 10:01

1 Answers1

0

Maybe your error is caused by the way you're invoking the REST API or maybe the projectKey is not correct (you need to use the project's key and not its name).

It's not clear exactly how you submited the report file but you can use a bash script to submit your results as follows. In this example, you will need to have an auxiliary file with your api key credentials, having something like: { "client_id": "215FFD69FE460000000000","client_secret": "2c00f8f22f56a8684d7518cd6147ce278700000000000000000000" }

Then you can execute the following script (copy it to a file named submit.sh, for example).

PROJECT=TM
TESTPLAN=
BROWSER=
token=$(curl -H "Content-Type: application/json" -X POST --data @"cloud_auth.json" https://xray.cloud.xpand-it.com/api/v2/authenticate| tr -d '"')
curl -H "Content-Type: application/xml" -X POST -H "Authorization: Bearer $token"  --data @"target/surefire-reports/testng-results.xml" "https://xray.cloud.xpand-it.com/api/v2/import/execution/testng?projectKey=$PROJECT&testPlanKey=$TESTPLAN&testEnvironments=$BROWSER"
Sérgio
  • 1,777
  • 2
  • 10
  • 12
  • even if i am manually uploading the testng report .xml through import execution UI its asking project name is missing – rahul mohanty Apr 27 '21 at 14:00
  • Do i have to add anything @Xray(ProjectName='QA') – rahul mohanty Apr 27 '21 at 14:13
  • No, you don't need to do that. Are you using @Xray annotation? if so, can you please share an example of the annotated test method? – Sérgio Apr 27 '21 at 16:17
  • the generated testng report xml works fine in another jira which doesnot have signoff project name associated.. i have attached the screenshot(attached screenshot doesnot work if this is ascociated) – rahul mohanty Apr 27 '21 at 16:47
  • Is it possible to pass project name in testng report .xml – rahul mohanty Apr 27 '21 at 17:12
  • @rahulmohanty, no that's not possible. – Sérgio Apr 29 '21 at 08:37
  • In order to understand exaclty what is the problem you're facing, we would need a bit more details, like the code snippet that you're using and the generate test report. My suggestion instead would be this: can you try following perhaps this tutorial? Maybe it can help out, as it provides a concrete example for TestNG. https://docs.getxray.app/display/XRAYCLOUD/Testing+using+TestNG+in+Java – Sérgio Apr 29 '21 at 08:40