如何使用 Jenkins xray 插件在不同端点上导入 Jira+Xray 上的执行结果?

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

我正在尝试将测试执行结果导入 jira+xray 并使用 Jenkins Xray 插件。 当我在路径 " /rest/raven/2.0/import/execution" 上手动 post 请求时,JSON 文件运行良好,但失败了在使用 Jenkins Xray 插件时。 我从 xray 文档 here 了解到 jenkins 插件使用端点 "/rest/raven/1.0/import/execution"。有没有办法在 jenkins xray 插件中将版本 1.0 更改为 2.0?

Jenkins xray 插件版本=> xray-connector:2.5.1

导致问题的 json 的 CustomFields 部分

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

这是我收到的错误消息,

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

正如我们所说,Xray plugin for Jenkins 使用 REST API 端点的 v1。 不幸的是,这是 non-configurable。这最终是有原因的:API 和 Xray JSON 中有一些小的变化被添加到 API.

的 v2 中

由于 Jenkins 的插件是由 Xray 团队自己完成和支持的,您可以联系 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。无论您选择哪种方法,请提供所有详细信息,以便团队进行分析。提前致谢。

作为解决方法,您可以在 jenkins 中配置 job/project 以使用 curl 或类似工具直接调用 REST API 来发出 POST 请求。

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