使用Azure Devops将自动化测试结果导入到Xray Cloud multipart



我正在尝试使用Azure Devops将结果导入x射线云多部分,这是我从yml配置文件中的bash命令:

token=$(curl -H "Content-Type: application/json" -X POST --data '{ "client_id": "$(client_id)","client_secret": "$(client_secret)" }' https://xray.cloud.xpand-it.com/api/v1/authenticate| tr -d '"')
curl -H "Content-Type: multipart/form-data" -X POST -F info=@pathissueFields.json -F results=@pathtargetsurefire-reportsTEST-TestSuite.xml -F testInfo=@pathtestIssueFields.json -H "Authorization: Bearer $token" https://xray.cloud.xpand-it.com/api/v1/import/execution/testng/multipart"

每次在管道控制台中我都收到这个错误:

"curl: (26) Failed to open/read local data from file/application
##[error]Bash exited with code '26'."

我做错了什么?

bash日志

Starting: Bash
==============================================================================
Task         : Bash
Description  : Run a Bash script on macOS, Linux, or Windows
Version      : 3.189.0
Author       : Microsoft Corporation
Help         : https://learn.microsoft.com/azure/devops/pipelines/tasks/utility/bash
==============================================================================

如果您使用的命令与您共享的完全相同,那么您必须有一个名为"path issuefields .json"的文件。我想这条"路径"不是真正的目录名。这同样适用于您标识的其他文件。所以curl命令应该是这样的:

curl -H "Content-Type: multipart/form-data" -X POST -F info=@issueFields.json -F results=@./target/surefire-reports/TEST-TestSuite.xml -F testInfo=@testIssueFields.json -H "Authorization: Bearer $token" https://xray.cloud.xpand-it.com/api/v1/import/execution/testng/multipart"

实现这一目标的另一种方法是在PowerShell中自动化XRay API。

方法如下:

  1. 添加"powershell">
  2. 选择"Type"作为"Inline">
  3. 输入脚本:

$Body = @{Client_id = "Client_secret = "}

$Parameters = @{Method = "POST"Uri = "https://xray.cloud.getxray.app/api/v1/authenticate"Body = $BodyContentType = "application/x-www-form-urlencoded"}

[净。ServicePointManager]:: SecurityProtocol =【净。SecurityProtocolType]:: Tls12

$token = Invoke-RestMethod @Parameters

$Header = @{"Authorization"= "持有人$token"}

$ FileContent =[IO.File]:: ReadAllText ((System.DefaultWorkingDirectory) EnterYourResultFilePath美元);

$Parameters = @{Method = "POST"Uri = "https://xray.cloud.getxray.app/api/v1/import/execution/junit?projectKey=ABCD&testPlanKey=ABCD-$(TestPlanKey)"Body = $FileContentHeaders = $HeaderContentType = "application/xml"}

Invoke-RestMethod @Parameters

我使用这个脚本将结果从XML文件上传到JIRA。

最新更新