我可以使用Jenkins API通过url获取关于我的构建的信息

http://localhost:8080/job/myjob/149/api/json

我希望能够使用tree query string参数查询变更集 node .我可以通过

http://localhost:8080/job/myjob/149/api/json?tree=duration

如何查询像变更集这样的索引 node ?我好像到处都找不到doctor .

{
    "actions": [
        {
            "causes": [
                {
                    "shortDescription": "Started by an SCM change"
                }
            ]
        },
        {},
        {},
        {}
    ],
    "artifacts": [],
    "building": false,
    "description": null,
    "duration": 80326,
    "estimatedDuration": 68013,
    "executor": null,
    "fullDisplayName": "my project #149",
    "id": "2013-06-14_14-31-06",
    "keepLog": false,
    "number": 149,
    "result": "SUCCESS",
    "timestamp": 1371234666000,
    "url": "http://localhost:8080/job/my project/149/",
    "builtOn": "",
    "changeSet": {
        "items": [
            {
                "affectedPaths": [
                    "SearchViewController.m",
                    "Sample.strings"
                ],
                "author": {
                    "absoluteUrl": "http://localhost:8080/user/my user",
                    "fullName": "My User"
                },
                "commitId": "9032",
                "timestamp": 1371234304048,
                "date": "2013-06-14T18:25:04.048031Z",
                "msg": "Author:my_author Description: changes Id: B-186199 Reviewer:reviewer_name",
                "paths": [
                    {
                        "editType": "edit",
                        "file": "/branches/project_name/iOS/_MainLine/project_name/SearchViewController.m"
                    },
                                       ],
                "revision": 9032,
                "user": "user_name"
            }
        ],
        "kind": "svn",
        "revisions": [
            {
                "module": "repo_url",
                "revision": 8953
            },
            {
                "module": "repo_url",
                "revision": 9032
            }
        ]
    },
    "culprits": [
        {
            "absoluteUrl": "http://localhost:8080/user/username",
            "fullName": "username"
        }
    ]
}

推荐答案

API文档有一个提示:

较新的替代方案是树查询参数.[Snip]你只需要知道你在寻找什么元素,而不是你在寻找什么(当插件可以贡献API元素时,这无论如何都是一个无限制的列表).该值应为要包括的属性名称列表,with subproperties inside square braces.

对于简单列表,使用以下命令获取整个子树:

http://jenkins/job/myjob/../api/json?tree=artifacts[*]

or list specific properties within the braces.

changeSet美元,使用

http://jenkins/job/myjob/../api/json?tree=changeSet[*[*]]

go 找回一切.

对特定的子属性使用嵌套的方括号,例如:

http://jenkins/job/myjob/../api/json?tree=changeSet[items[revision]]

树文档表示,它适用于调用方不知道要检索哪些属性的情况.

Json相关问答推荐

JOLT拉平数组

从先前的REST调用创建动态JSON主体

使用JQ从jsonl文件中删除具有匹配键/值的行

有没有办法让serde_json正确/不正确地处理NaN、inf和-inf(IEEE 754特殊标准)?

无法访问id的第三级json

如何在Android中解析带有动态键和可变对象名称的改装JSON响应?

使用 jq 重新格式化 JSON 输出

使用 jolt 变换压平具有公共列 JSON 的复杂嵌套

用powershell条件解析json文件的数组对象

为什么根据其他工具,来自 aws rds 的 JSON 在 Docker 中格式错误运行?

Flutter:在本地文件 json 中搜索特殊的阿拉伯字符

如何为包含一些固定值并可能具有其他附加值的数组字符串创建数组 json 架构

如何在 onClick 事件处理程序中识别在同一 map 上绘制的多个多边形中的哪个(使用 react-leaflet)被单击?

如何在 jQuery 中循环遍历 JSON 数组?

如何使用 CORS 实现 JavaScript Google Places API 请求

Jackson 的@JsonView、@JsonFilter 和 Spring

如何一次加载无限滚动中的所有条目以解析python中的HTML

如何自动修复无效的 JSON 字符串?

将 javascript 对象或数组转换为 json 以获取 ajax 数据

Gson 将一组数据对象转换为 json - Android