博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Jenkins--02命令行构建Job
阅读量:6910 次
发布时间:2019-06-27

本文共 1432 字,大约阅读时间需要 4 分钟。

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

你可能感兴趣的文章
Android 开发笔记 “SharePreference 数据存取”
查看>>
C#常用IO流与读写文件
查看>>
record-05 函数
查看>>
ajax 跨域
查看>>
patch similarity
查看>>
WCF分布式开发步步为赢(1):WCF分布式框架基础概念
查看>>
一次编程中无意碰见的问题
查看>>
docker常用命令
查看>>
POJ 1979 红与黑
查看>>
Excel基础知识(一)
查看>>
网络编程 ------ 基础
查看>>
10.31T3 其他算法思想
查看>>
Java 线程 — ScheduledThreadPoolExecutor
查看>>
Microsoft Dynamics CRM 常用JS语法(已转成vs2017语法提示)
查看>>
map()和filter()和reduce()函数
查看>>
python从入门到实践-8章函数
查看>>
3.MyBatis常用
查看>>
WEB学习
查看>>
Algorithm | Sort
查看>>
TF-IDF与余弦相似性的应用(一):自动提取关键词
查看>>