jenkins api
http://jen-server:8080/job/<view>/api/json
http://jenkins_site/computer/api/json?depth=1&pretty=true
1.LastBuild信息,这是一个build信息的字典:
可以获取值
"name":"GERRIT_CHANGE_NUMBER","value":"150410"
"name":"GERRIT_PATCHSET_NUMBER","value":"7"
"name":"GERRIT_REFSPEC","value":"refs/changes/10/150410/7"
"name":"GERRIT_CHANGE_URL","value":"https://git-1.devtools/gerrit/150410"}
"runs":[{"number":135,"url":"http://jen-server:8080/job/PRE_CI/label=master/135/"}
http://jen-server:8080/job/PRE_CI/lastBuild/api/json?prettye=true
2. 队列信息:
http://jen-server:8080/queue/api/json
items对应的是一个列表,不包含正在build的job
可以取到排队的task信息:
"name": "GERRIT_CHANGE_NUMBER",
"value": "150654"
"name": "GERRIT_PATCHSET_NUMBER",
"value": "7"
"id": 6414, #queueid
"url": "queue/item/6414/"
"name": "GERRIT_CHANGE_URL",
"value": "https://git-1.devtools:gerrit/150654"
3.取消任务队列
cancel 取消任务队列
POST http://127.0.0.1:8080/cancelItem?id={id}
4.停止构建:
baseURL=<jenkins url>/view/<view name>/job/<job name>
API: baseURL/<id>/stop
Reference:
https://blog.csdn.net/qq_34832393/article/details/88210942
https://blog.csdn.net/qq_34832393/article/details/88229804
https://www.jianshu.com/p/d77c6a7ec724