


下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、持续集成JenkinsAPI常见用法jenkins持续集成开源工具提供了丰富的api接口,根本上所有的操作都可以使用curl来从后台调度,包括:创建项目,禁用项目,启用项目,获取项目描述,获取配置文件,普通触发,scm触发,带参数触发,带补丁触发。【背景】:部门在搞持续集成,使用jenkins 作为核心调度,要再其根底上进展二次封装,所以需要研究下jenkins 的api。笔者主要负责搭建平台,在研究用法也花费了些时间,本文主要做个简要的记录,希望能为各位朋友节省时间。【环境】:默认读者已经具备了根本的持续集成经验和jenkins 用法1.2.系统Suse5. patch-parameter【
2、API介绍】Jenkins 提供了 html、json、python API,实质都是以get/post 方式调用的。查看.xxx.xxx/jenkins/api/即可得到相应的说明,如图:由电 md Is also avail able.Ycu rar ?lsa =pecrhr opnoncil XPgth to- control Che Vagment you d li卜-tc obtan :birr sfp 匕曰口训.For exartle, .【D:. f the XPath Qdlhn miatches a tet noder theesju止 imiI be i匚.% Il iJS
3、OMAP1Access ii色邑an色 data 总弓 iStJ N Par javaSmpE-baed &亡色弓弓-&jppcirts I UH through 出色 Dponrial 相戶 pdJJzrJfcr 口Ur p)iirPvrhcn 戌卩I人亡t锂冒!s ii色邑古m空日首甜 占弓 PyE3ii for P /thon clients. This can b# parsed into Python obj-scr as Qgfcriiih- a-Upg 化 xa 诅 1B and the rsuftng object tr& is identicfil to Ithiat of
4、J SON Howftv*.whep you do t+iis. beware cF Fa %产口旧厲 irriiliratirn, f you nre rnnerting to 耳 nor-tnjslrprl 已hkin勺 the 百三电can send vou malKicus Python proqrams.For more informa jinn alb out remoEe API in Jenkins ses tie dpcjrrentatiori.Controlling the amount of data you fetcltIn all formatsH th毛psrame
5、tr cantci contrd amount ordsvctjII rwsive. Th宕 d-?Faultns lepih=O b Lrt: by increasing alkje #ou csn 石Et a tor of ctats by single remctE API imT TaOon ;the dov/TisidE ts bigger bandwidth rgqui乜 eghL) Compare, daptim and 0 曰些三 JL and wh=at the differ once is for yourself. a|io note that data created
6、tw a smaler depth vaue is always a suibset of the data created by a bigger 4 pii luw.A riHx yr dltf=ir alive us Hit tr4.b. with excidi- since informs on does nor need to be acnerated on rhe setver and ttien dim 站 nd mflv btc Eincs you n-d only know what尹 looking for. rathsr than sttin sq 寸口Lam see s
7、amples uf iliEin in 八二st-/丄此门“疏旦讨刖止*pp討血二加curl -X POST .xxx.xxx/jenkins/createltem?name=JavaStd-user peterguo:peterguo-data-binary javastd.config.xml -H Content-Type: text/xml2.禁用curl -X POST .xxx.xxx/jenkins/job/JavaStd/disable-user peterguo:peterguo3.启用curl -X POST .xxx.xxx/jenkins/job/JavaStd/ena
8、ble -user peterguo:peterguocurl -X POST .xxx.xxx/jenkins/job/JavaStd/doDelete -user peterguo:peterguo5. 获取项目描述curl -X GET .xxx.xxx/jenkins/job/JavaStd/description -user peterguo:peterguo6. 获取配置文件curl -X GET .xxx.xxx/jenkins/job/JavaStd/config.xml -user peterguo:peterguo7. 触发SCM检查curl -X GET .xxx.xxx
9、/jenkins/job/JavaStd/polling -user peterguo:peterguo8. 普通触发curl -X GET .xxx.xxx/jenkins/job/JavaStd/build -user peterguo:peterguocurl -X GET.xxx.xxx/jenkins/job/helloworld-freestyle/buildWithParameters?bAIITest=&Choices=2&strParam=abc -user peterguo:peterguo10.带参数和补丁触发curl -X POST.xxx.xxx/jenkins/jo
10、b/helloworld-freestyle/buildWithParameters?bAIITest=&Choices=2&strParam=abc -user peterguo:peterguo -F action=upload -Fpatch.diff=OtherTest.java.patch注:带补丁触发需要先安装补丁插件,并设置项目的补丁参数増加参埶-f Boolean ValueChoiceFile ParameterList Sub version tags (and more)Password ParameterPatch fileas a parameterRun Param
11、eter. String ParameterText Parameter【Python 调用】提供python 使用pycurl调用的例子片段,实际和 curl调用一样,优点是易整合。view source print?01 import pycurl 02 url = 10.129.145.112:8081/jenkins/job/helloworld-freestyle/config.xml03 crl = pycurl.Curl()04 crl.setopt(pycurl.VERBOSE,1) |05 crl.setopt(pycurl.FOLLOWLOCATION, 1)06 crl.setopt(pycurl.MAXREDIRS, 5)07 crl.setopt(pycurl.USERPWD, peterguo:peterguo)0809 crl.setopt(pycurl.CONNECTTIMEOUT, 60)10 crl.setopt(pycurl.TIMEOUT, 300)11 cr
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 山西省忻州地区2023-2024学年七年级下学期期中双减成果展示数学试卷(含解析)
- 全球造纸市场供需趋势考核试卷
- 印刷过程余热回收技术考核试卷
- 生产效率提升策略考核试卷
- 纸质包装的防水防油技术研究考核试卷
- 2025年中国PEV薄膜数据监测报告
- 2025年中国DVI产品数据监测研究报告
- 2025年中国60匙位智能钥匙管理系统主机数据监测报告
- 2025年中国16支棉纱数据监测报告
- 2025至2030年中国高浓度聚合硫酸铁市场分析及竞争策略研究报告
- 计量经济学论文eviews
- 优生优育课件-提高生育健康水平
- 父母与高中生之间的协议书
- 2022年韶关市法院系统招聘考试真题
- 2022年江苏省射阳中等专业学校工作人员招聘考试真题
- 高中英语新课程标准试题含答案(四套)
- 公安院校公安专业招生体检表
- 警务辅助人员考试真题及答案
- 2023年安龙县体育教师招聘笔试模拟试题及答案
- GB/T 27922-2011商品售后服务评价体系
- GA/T 168-2019法医学机械性损伤尸体检验规范
评论
0/150
提交评论