Asanke
Asanke

Reputation: 601

"error": "Error creating issues in Jira!" when trying to publish test results to xray

I am trying to integrate some junit xml results in to my JIRA/Xray test run. I have created the simplest result.xml

<?xml version="1.0" encoding="UTF-8" ?>
<testsuite name="account_settings.spec.ts" timestamp="2025-01-21T05:39:49.602Z" hostname="chromium" tests="1" failures="0" skipped="0" time="9.129" errors="0">
  <testcase name="Account settings ... Edit Account details of a admin user @account_detail" classname="account_settings.spec.ts" time="9.129"/>
</testsuite>

The call I am making to publish (Import Execution Results - REST, as per xray documentation) is follows... Try 1:

curl -v -H "Content-Type: text/xml" -X POST -H "Authorization: Bearer $TOKEN" --data @"results.xml" https://xray.cloud.getxray.app/api/v2/import/execution/junit?projectKey=PRJ

Try 2:

curl -v -H "Content-Type: text/xml" -X POST -H "Authorization: Bearer $TOKEN" --data @"results.xml" https://xray.cloud.getxray.app/api/v2/import/execution/junit?testExecKey=PRJ-16&projectKey=PRJ

Here PRJ is my Jira project that has Xray integrated. PRJ-16 is my "Test Execution" ticket which contains one test in it.

The response for this comes in as

{ "error": "Error creating issues in Jira!" }

What am I dong wrong here?

Upvotes: 0

Views: 55

Answers (2)

Asanke
Asanke

Reputation: 601

Thanks Sérgio,

It was custom fields. We had a custom field in our Jira that prevented the call. I had to use the JUnit multipart api to get that sorted.

/ # curl -H "Content-Type: multipart/form-data" -X POST -F [email protected] -F [email protected] -F [email protected] -H "Authorization: Bearer $TOKEN" https://xray.cloud.getxray.app/api/v1/import/execution/junit/multipart
        {"id":"16736","key":"PRJ-199","self":"https://mydomain/rest/api/2/issue/136"}/ 
  #

So I ended up these information passed in from testIssueFields.json and testExec.json Thanks!

Upvotes: 0

S&#233;rgio
S&#233;rgio

Reputation: 2129

The error returned by the API doesn't provide much details but we can can provide some clues to what may be causing it.

Xray cloud API will internally invoke Atlassian APIs to create Test and Test Execution issues. Sometimes that may fail because the user for whom you created the Xray API key credentials (client id + client secret) is not allowed to create those issue types on the target Jira project. This happens frequently.

Also, sometimes Jira/project administrator add required fields for those issue types on the target Jira project, which will lead to a failure if we try to create them without specifying values for those fields.

Therefore, the recommendation would be as follows:

  • try, as the given authorized Jira user, to create Test and Test Execution issues on the target project; if you can't, then you have found the reason; if you can but you have to provide additional values for some custom fields, then you need to use the junit multipart endpoint, which allows passing additional fields to customize the target Test and Test Execution issues
  • if the previous don't work, you should reach out to Xray support team as they might have access to additional information that is not exposed on the error message returned on the API call (as it is just too generic)

Upvotes: 1

Related Questions