3.4.1、按照插件
https://mirrors.tuna.tsinghua.edu.cn/jenkins/plugins/gradle/latest/
3.4.2、配置jenkins
3.4.2、编写jenkinsfile
#!groovy
String buildShell = "${env.buildShell}" //引用参数
pipeline {
agent {
node {
label "master" //构建主机
}
}
stages {
stage("mvnBuild") {
steps {
script {
mvnHome=tool "m2" //引用工具
sh "${mvnHome}/bin/mvn ${buildShell}" //引用参数变量
}
}
}
stage("antBuild") {
steps {
script {
try{ //防止异常终止执行
AntHome=tool "ant" //引用工具
sh "${AntHome}/bin/ant ${buildShell}" //引用参数变量
} catch(e){
println(e)
}
}
}
}
stage("npmBuild") {
steps {
script {
NpmHome=tool "NPM" //引用工具
sh "${NpmHome}/bin/npm ${buildShell}" //引用参数变量
}
}
}
stage("gradleBuild") {
steps {
script {
NpmHome=tool "Gradle" //引用工具
sh "${NpmHome}/bin/gradle ${buildShell}" //引用参数变量
}
}
}
}
}