Search code examples
jenkinsjira-pluginjira-xray

How to import execution result on Jira+Xray on a different endpoint with Jenkins xray plugin?


I am trying to import test execution results to jira+xray and using the Jenkins Xray plugin. The JSON file works well when I manually post a request on the path " /rest/raven/2.0/import/execution", but fails while using the Jenkins Xray plugin. I understand from the xray documentation here that jenkins plugin uses the endpoint "/rest/raven/1.0/import/execution". Is there a way to change version 1.0 to 2.0 in jenkins xray plugin?

Jenkins xray plugin version=> xray-connector:2.5.1

CustomFields part of the json that is causing the issue

            "customFields": [{
                "id": 10,
                "value": "test"
                },
                {
                "id": 4,
                "value": "test1"
                },
                {
                "id": 6,
                "value": "test2"
                },
                {
                "id": 8,
                "value": "test3"
                }]

This is the error message I get,

ERROR: Unable to confirm Result of the upload..... Upload Failed! Status:400 Response:You can't import Test Runs Custom Fields using the v1 REST API

Solution

  • The Xray plugin for Jenkins, as we speak, uses v1 of the REST API endpoints. Unfortunately this is non-configurable. There's eventually a reason for it: there were some small changes in the API and Xray JSON that were added into v2 of the API.

    Since the plugin for Jenkins is done and supported by the Xray team itself, you may reach out to Xray support and ask for an improvement so that it provides support for v2 of the APIs and underlying features. Please also, if you can, provide the Xray JSON you would like to submit and that you cannot do nowadays while using the current version of the plugin. In alternative, you may raise directly an issue in the open-source repository on GitHub. Whatever approach you chose, please provide all the details so the team can then analyze it. Thanks in advance.

    As a workaround, you may configure your job/project in jenkins to invoke the REST API directly using curl or similar tool to make the POST request.

    curl -H "Content-Type: application/json" -X POST -u jirausername:jirapassword --data @data.json http://yourserver/rest/raven/2.0/import/execution