访问Jenkins API的几个小trick
1. 根据jenkins页面的url,加/api/xml或/api/json即可访问xml或json的输出
e.g. http://jenkinsHost/job/jobname/buildNum/plugin/api/json
2. 用pretty参数规整输出可读
e.g. http://jenkinsJob/api/json?pretty=true
3. 用depth参数指定要获取的层次
e.g. http://jenkinsJob/api/json?depth=2
4. 用&连接参数
e.g. http://jenkinsJob/api/json?depth=2&pretty=true
5. 但是用curl访问时,linux系统会将&解析为放在后台执行的命令,所以url需用引号括起来
e.g. curl 'http://jenkinsJob/api/json?depth=2&pretty=true'
6. 用tree指定要访问的node节点
e.g. http://jenkinsJob/api/json?tree=results[elements[*]]
7. 但是用curl访问时,方括号需用反斜线转义
e.g. curl -s 'http://jenkinsJob/api/json?pretty=true&tree=results\[elements\[*\]\]'
e.g. http://jenkinsHost/job/jobname/buildNum/plugin/api/json
2. 用pretty参数规整输出可读
e.g. http://jenkinsJob/api/json?pretty=true
3. 用depth参数指定要获取的层次
e.g. http://jenkinsJob/api/json?depth=2
4. 用&连接参数
e.g. http://jenkinsJob/api/json?depth=2&pretty=true
5. 但是用curl访问时,linux系统会将&解析为放在后台执行的命令,所以url需用引号括起来
e.g. curl 'http://jenkinsJob/api/json?depth=2&pretty=true'
6. 用tree指定要访问的node节点
e.g. http://jenkinsJob/api/json?tree=results[elements[*]]
7. 但是用curl访问时,方括号需用反斜线转义
e.g. curl -s 'http://jenkinsJob/api/json?pretty=true&tree=results\[elements\[*\]\]'
评论
发表评论