![](https://img2018.cnblogs.com/blog/925455/201906/925455-20190626172445711-298632648.png)
脚本
node('master') {
def mvnHome = tool 'maven11-free'
def gitUrl = "http://gitlab.wdcloud.cc:10080/utility/rps/rps.git"
def appName = "rps-module-admin"
def appPath = "/wdcloud/app/rps/rps-module-admin"
def nodeIp = "10.1.6.152"
def configIp = "10.1.6.154"
def profile = "prod"
stage('rmdir') {
sh "rm -rf ./*"
}
stage('git') {
git branch: 'master', credentialsId: 'b05692e9-6625-4540-9b50-577254d4732b', url: "${gitUrl}"
sh 'git checkout ${tag}'
sh """scp rps-modules/${appName}/src/main/resources/application-${profile}.yml jetty@${configIp}:/wdcloud/config-repo/rps/${appName}-${profile}.yml"""
}
stage('Package') {
sh "'${mvnHome}/bin/mvn' -Dmaven.test.failure.ignore -Dmaven.test.skip=true clean package"
}
stage('Deployment'){
sh """
ssh -p61234 jetty@${nodeIp} "${appPath}/${appName}.sh stop || echo not running"
ssh -p61234 jetty@${nodeIp} "rm -rf ${appPath}/${appName}-*.jar"
scp -p61234 -o StrictHostKeyChecking=no -r rps-modules/${appName}/target/${appName}-*.jar jetty@${nodeIp}:${appPath}/
ssh -p61234 jetty@${nodeIp} "${appPath}/${appName}.sh start || echo not running"
"""
}
}