这是一种通过Jenkins2 REST调用获取选定内部版本信息的方法,但不了解作业名称(即不是每个作业,而是来自所有内部版本),类似于SQL:
select number,result from all_builds_in_jenkins;
?
答案 0 :(得分:1)
您可以使用以下get命令将所有内容保存在json文件中:
http://jenkins.example.com/api/json?tree=jobs[name,builds[number,actions[parameters[name,value]]]]&pretty=true
示例输出:
{
"jobs" : [
{
"name" : "Job name - Build",
"builds" : [
{
"actions" : [
{
"parameters" : [
{
"name" : "GIT_COMMIT_PARAM",
"value" : "5447e2f43ea44eb4168d6b32e1a7487a3fdf237f"
}
]
},
(...)
如果仅需要作业列表:
http://jenkins.example.com/api/json?tree=jobs[name,color]&pretty=true
示例输出:
{
"_class" : "hudson.model.ListView",
"jobs" : [
{
"_class" : "com.cloudbees.hudson.plugins.folder.Folder",
"name" : "DEV"
},
{
"_class" : "com.cloudbees.hudson.plugins.folder.Folder",
"name" : "Libs"
},
{
"_class" : "hudson.model.FreeStyleProject",
"name" : "Dummy project",
"color" : "red"
},
]
}