gpt4 book ai didi

azure - 如何从 Azure Devops REST API 仅返回特定属性

转载 作者:行者123 更新时间:2023-12-02 06:41:44 26 4
gpt4 key购买 nike

我正在尝试使用以下命令获取 Azure Devops 中特定项目的所有构建详细信息获取:https://dev.azure.com/{organization}/{project}/_apis/build/builds?api-version=5.1

此 API 返回具有许多属性的 JSON 对象。在 Jenkins API 中,我们可以仅过滤所需的属性。Azure Devops API 中是否有类似的方法?

根据文档https://learn.microsoft.com/en-us/rest/api/azure/devops/build/builds/get?view=azure-devops-rest-5.1,我尝试使用 propertyFilter 但没有帮助我。

任何帮助或指示都会有用。

最佳答案

从 DevOps 返回的 JSON 看起来非常像这样:

{
"count": 1000,
"value": [
{
"id": ,
"buildNumber": "",
"status": "",
"result": "",
"queueTime": "",
"startTime": "",
"finishTime": "",
"url": "",
"definition": {
"drafts": [

],
"id": ,
"name": "",
"url": "",
"uri": "",
"path": "",
"type": "",
"queueStatus": "",
"revision": ,
"project": {
"id": "",
"name": "<NAMEOFYOURPROJECT>",
"url": "",
"state": "",
"revision": ,
"visibility": "",
"lastUpdateTime": ""
}
},
"buildNumberRevision": 2,
"project": {
"id": "",
"name": "<NAMEOFYOURPROJECT>",
"url": "",
"state": "",
"revision": ,
"visibility": "",
"lastUpdateTime": "2"
},
...

您要查找的过滤键是 project/name .

要过滤的 ODATA 查询字符串 project/name看起来像这样: https://dev.azure.com/{organization}/{project}/_apis/build/builds?api-version=5.1&$filter=startswith(project/name,'<NAMEOFYOURPROJECT>')

关于azure - 如何从 Azure Devops REST API 仅返回特定属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61094169/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com