如何使用Jenkins远程API中的树查询参数来获取下游项目和参数?
我正在尝试使用 Jenkins(Hudson) 远程 API 来使用来自 freeStyleProject 的 XML 响应。
研究 Jenkins 文档 中的树查询参数和 < a href="https://stackoverflow.com/questions/4722345/how-to-get-a-better-performance-from-hudson-ci-api">这里我一直在尝试使用它缩短获取 XML 响应的响应时间。但是 Jenkins 似乎无法使用以下 URL 生成作业的下游项目节点和构建的操作/参数:
http://localhost/job/MyJob/api/xml?depth=2&tree=名称,描述,构建[操作[参数[名称,值]]数字,url,timestamp,result],healthReport[score,description],downstreamProject[name,url]
我刚刚得到此响应 XML:
<freeStyleProject>
<description>Description</description>
<name>MyJob</name>
<build>
<number>2</number>
<result>SUCCESS</result>
<timestamp>1325784290000</timestamp>
<url>http://localhost/job/MyJob/2/</url>
</build>
<build>
<number>1</number>
<result>SUCCESS</result>
<timestamp>1323931754000</timestamp>
<url>http://localhost/job/MyJob/1/</url>
</build>
<healthReport>
<description>Build stability: No recent builds failed.</description>
<score>100</score>
</healthReport>
</freeStyleProject>
也许树查询参数不支持这些?使用 xpath 和排除查询参数获取此节点的唯一方法是吗?
I am trying to use Jenkins(Hudson) Remote API to consume XML response from a freeStyleProject.
Researching about the tree query parameter in the Jenkins documentation and here I have been trying to use it to improve response times to get XML response. But Jenkins seems to be unable to generate the nodes downstreamProject of the job and the action/parameter of the builds with this URL:
http://localhost/job/MyJob/api/xml?depth=2&tree=name,description,builds[action[parameter[name,value]]number,url,timestamp,result],healthReport[score,description],downstreamProject[name,url]
I just get this response XML:
<freeStyleProject>
<description>Description</description>
<name>MyJob</name>
<build>
<number>2</number>
<result>SUCCESS</result>
<timestamp>1325784290000</timestamp>
<url>http://localhost/job/MyJob/2/</url>
</build>
<build>
<number>1</number>
<result>SUCCESS</result>
<timestamp>1323931754000</timestamp>
<url>http://localhost/job/MyJob/1/</url>
</build>
<healthReport>
<description>Build stability: No recent builds failed.</description>
<score>100</score>
</healthReport>
</freeStyleProject>
Perhaps the tree query parameter does not support these? Would the only way to get this nodes using the xpath and exlude query parameters?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于“tree”参数,您要查找的部分是复数(其中有单数)。
行动=>动作
参数=>参数
downstreamProject => 因此,您的网址
将是:
http://localhost/job/MyJob/api/xml?depth=2&tree=name,description,builds[actions[parameters[name,value]],number,url,timestamp,结果],healthReport[分数,描述],downstreamProjects[名称,url]
For the "tree" parameter, the pieces you are looking for are plurals (where you have singulars).
action => actions
parameter => parameters
downstreamProject => downstreamProjects
So, your url would be:
http://localhost/job/MyJob/api/xml?depth=2&tree=name,description,builds[actions[parameters[name,value]],number,url,timestamp,result],healthReport[score,description],downstreamProjects[name,url]