jenkins集成maven
来源:原创
时间:2020-10-24
作者:脚本小站
分类:Jenkins
在jenkins主机上安装maven:
www.scriptjc.com/article/1056
在jenkins中配置mvn:
在groovy脚本中:
#!groovy pipeline{ agent{ node{ label "master" } } options { timestamps() //日志会有时间 skipDefaultCheckout() //删除隐式checkout scm语句 disableConcurrentBuilds() //禁止并行 timeout(time: 1, unit: 'HOURS') //流水线超时设置1h } stages{ stage("push jar"){ steps{ script{ println("开始推包"); } } } stage("pushing"){ steps{ script{ println("pushing....."); // 通过tool 指令来获取mvn的安装目录 mvnhome = tool "M2" println(mvnhome) sh "${mvnhome}/bin/mvn -v" //直接路径方式 mvnHome = "/usr/local/maven/bin" println(mvnHome) sh "${mvnhome}/bin/mvn -v" } } } stage("push over"){ steps{ script{ println("推包完成"); } } } } post { always { script{ println("always") } } success { script{ currentBuild.description = "\n 构建成功!" } } failure { script{ currentBuild.description = "\n 构建失败!" } } aborted { script{ currentBuild.description = "\n 构建取消!" } } } }
常用maven命令:
clean:清理构建目录
clean package:打包
clean install:打包部署
clean test:单元测试