在构建成功/失败后,我正在尝试将构建管道的状态发送到 Bitbucket Server。使用 Postman,我可以使用 REST API 成功更新提交的构建状态:
POST https://bitbucketserver/rest/build-status/1.0/commits/dac37f9ede70e9548528a1dd19409b352db624e6
204
177 ms
Warning: Self signed certificate in certificate chain
POST /rest/build-status/1.0/commits/dac37f9ede70e9548528a1dd19409b352db624e6 HTTP/1.1
Authorization: Basic eHhrbGk6MjlOb3ZlbWJlcjIwMjA=
Content-Type: application/json
User-Agent: PostmanRuntime/7.26.8
Accept: */*
Postman-Token: e88d324b-e014-48e6-9a4c-5ad094e49aed
Host: nibcoderepo:7990
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Content-Length: 220
{
"state": "SUCCESSFUL",
"key": "Project",
"name": "CI-Build",
"url": "https://devops/Project/Repo/_build",
"description": "Build status from Azure Devops Server"
}
HTTP/1.1 204 No Content
但是,当我尝试在管道中的无代理作业中运行 Invoke REST API 时,请求失败并且无法找到服务器。这是作业日志的输出:
==============================================================================
Task : Post build status
Description : Invoke a REST API as a part of your pipeline.
Version : 1.152.1
Author : Microsoft Corporation
Help URL : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/http-rest-api
==============================================================================
Parsing expression: <TaskInputs[TaskInputs['connectedServiceNameSelector']]>
TaskInputs
[
..TaskInputs
..[
....'connectedServiceNameSelector'
..]
]
Evaluating: TaskInputs[TaskInputs['connectedServiceNameSelector']]
Evaluating indexer:
..Evaluating TaskInputs:
..=> Object
..Evaluating indexer:
....Evaluating TaskInputs:
....=> Object
....Evaluating String:
....=> 'connectedServiceNameSelector'
..=> 'connectedServiceName'
=> '3f2eef60-1c18-4d2d-95ef-20b9946e6a16'
Result: '3f2eef60-1c18-4d2d-95ef-20b9946e6a16'
POST https://bitbucketserver//rest/build-status/1.0/commits/b63a3c20f0b0df1fcaa163284f82e6efa9e84437
Request body: {
"state": "SUCCESSFUL",
"key": "Project",
"name": "CI-Build",
"url": "https://devops/Project/Repo/_build/results?buildId=822",
"description": "Build status from Azure Devops Server"
}
Response Code: 0
Response: An error was encountered while processing request. Exception: <!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><title>Oops, can't find that - Bitbucket</title><script>
....
Exception Message: The remote server returned an error: (404) Not Found. (type WebException)
我能够从 Azure DevOps 机器运行 Postman 请求,因此不存在防火墙问题。有趣的是,我注意到 REST 调用的地址在机器地址之后有一个奇怪的 //,不知道这是否会导致问题......?
由于 Azure DevOps 构建管道中没有执行后门(类似于发布门),我还没有找到更好的方法来执行此操作。
还有其他人在这方面取得成功吗?
谢谢,卡里