Jenkins--02命令行构建Job

1.查看说明并下载文件

1.1 下载jenkins-cli.jar:http://127.0.0.1:8080/jenkins/cli

1.2 jenkins-cli.jar命令帮助:java -jar jenkins-cli.jar -s http://127.0.0.1:8080/jenkins/ -help

 

2.使用build命令构建一个Job

java -jar jenkins-cli.jar -s http:// 127.0.0.1:8080/jenkins/  build JOBNAME  -p  tag=xxx --username xxx --password xxx
 
说明:
1. build后面直接跟JOB的名字
2. -p后面跟参数化构建的参数,使用key=value格式。如果有多个参数就写多个-p
3.—username和--password提供jenkins的账号密码
 

build的使用方法:
JOB : Name of the job to build
    要创建的作业的名称
-c  : Check for SCM changes before starting the build, and if there's no change, exit without doing a build
    在开始构建之前检查SCM更改,如果没有更改,退出而不进行构建
-f  : Follow the build progress. Like -s only interrupts are not passed through to the build.
    按照生成进度。像-s仅中断不会传递给构建。
-p  : Specify the build parameters in the key=value format.
    在KEY=值格式中指定生成参数
-s  : Wait until the completion/abortion of the command. Interrupts are passed through to the build.
    等待命令完成/堕胎。中断被传递到构建。
-v  : Prints out the console output of the build. Use with -s
    打印出构建的控制台输出。使用-s
-w  : Wait until the start of the command
    等待命令的开始

3.获得历史构建的参数

获取上次构建结果:
curl  "http:// 127.0.0.1:8080/jenkins/view/app/job/ JOBNAME/lastBuild/api/xml”
 
然后可以解析结果,可以通过expr在shell中解析,获得需要的参数,例如获得tag:
expr "$result" : '.*<name>tag</name><value>\([a-zA-Z0-9_-]*\)</value></parameter>'
 
说明:$result为请求上次构建的结果,tag这里匹配的是字母数字和下划线中横线

 

以上内容参考地址:https://www.cnblogs.com/meitian/p/7609178.html

转载于:https://www.cnblogs.com/cevinchen/p/9350272.html

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值