


下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- (一模)萍乡市2025年高三第一次模拟考试政治试卷(含答案解析)
- 2025年中考道德与法治二轮复习:文明与精神 高频考点学案(含练习题及答案)
- 施工水源施工方案
- 阜阳机房消防施工方案
- 别墅独院出租合同范例
- 双方签合同范例
- 建设工地保安工作流程与重点计划
- 学校美术教育品牌形象建设计划
- 人性化管理方案计划
- 社会实践与校外教学活动安排计划
- 国产自主可控数据库采购项目技术标准和服务要求
- 机械设计说明书-激光熔覆送粉器设计
- 沥青砼质量控制点及措施
- imedical8 1 0医生站配置手册
- RB/T 089-2022绿色供应链管理体系要求及使用指南
- 家用牙齿美白仪对牙齿漂白的临床应用效果研究
- 李博《生态学》课后习题答案
- 生化检验质控及失控分析
- 永磁同步电机地设计与电磁分析报告
- 全国各大媒体的报料热线电话号码
- 催化材料智慧树知到答案章节测试2023年南开大学
评论
0/150
提交评论