首页 > 其他 > 详细

Jenkins--02命令行构建Job

时间:2018-07-22 15:44:54      阅读:173      评论:0      收藏:0      [点我收藏+]

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

Jenkins--02命令行构建Job

原文:https://www.cnblogs.com/cevinchen/p/9350272.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!