Search code examples
jira-xray

"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?


Solution

  • 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)