|
@@ -4,6 +4,7 @@ pipeline {
|
|
|
environment {
|
|
|
def appName = "jp-employment"
|
|
|
def branch = "master"
|
|
|
+ def host = '121.37.187.149'
|
|
|
}
|
|
|
|
|
|
tools {
|
|
@@ -24,7 +25,7 @@ pipeline {
|
|
|
stage('package') {
|
|
|
steps {
|
|
|
dir("${env.WORKSPACE}/code"){
|
|
|
- sh 'mvn clean package -Dmaven.test.skip=true -P test -s /usr/maven/apache-maven-3.3.9/conf/settings.xml'
|
|
|
+ sh 'mvn -s "/usr/local/maven/apache-maven-3.3.9/conf/jenkins.xml" clean package -Dmaven.test.skip=true -P test'
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -33,33 +34,42 @@ pipeline {
|
|
|
steps {
|
|
|
script {
|
|
|
dir("${env.WORKSPACE}/code/web/target") {
|
|
|
- def host = '121.37.187.149'
|
|
|
-
|
|
|
- withCredentials([usernamePassword(credentialsId: '${host}',
|
|
|
+ withCredentials([usernamePassword(credentialsId: host,
|
|
|
passwordVariable: 'pwd', usernameVariable: 'userName')]) {
|
|
|
def sshServer = [:]
|
|
|
|
|
|
sshServer.name = 'huawei server'
|
|
|
- sshServer.host ='${host}'
|
|
|
-
|
|
|
+ sshServer.host = host
|
|
|
sshServer.user = userName
|
|
|
sshServer.password = pwd
|
|
|
-
|
|
|
sshServer.allowAnyHosts= true
|
|
|
|
|
|
- sshCommand remote: sshServer, command: "docker stop ${appName}-server"
|
|
|
+ sshCommand remote: sshServer, command: "docker stop ${appName}"
|
|
|
+
|
|
|
+ def targetFolder = "/opt/mydocker/tomcat8/jp-employment/webapps"
|
|
|
+
|
|
|
+ if(fullUpdate=='true'){
|
|
|
+ sh "mv web-1.0.0.war web.zip"
|
|
|
+ sshPut remote: sshServer, from: 'web.zip', into: targetFolder
|
|
|
+ sshCommand remote: sshServer, command: "rm -rf ${targetFolder}/${appName}-server"
|
|
|
+ sshCommand remote: sshServer, command: "unzip ${targetFolder}/web.zip -d ${targetFolder}/${appName}-server"
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ //更新 classes
|
|
|
+ dir("${env.WORKSPACE}/code/web/target/web-1.0.0/WEB-INF/classes"){
|
|
|
+ sh 'tar -czvf com.tar.gz com'
|
|
|
+ sshPut remote: sshServer, from: 'com.tar.gz', into: "${targetFolder}/${appName}-server/WEB-INF/classes"
|
|
|
+ sshCommand remote: sshServer, command: "rm -rf ${targetFolder}/${appName}-server/WEB-INF/classes/com"
|
|
|
+ sshCommand remote: sshServer, command: "tar -zxvf ${targetFolder}/${appName}-server/WEB-INF/classes/com.tar.gz -C ${targetFolder}/${appName}-server/WEB-INF/classes"
|
|
|
+ }
|
|
|
|
|
|
- if(fullUpdate){
|
|
|
- def targetFolder = '/opt/mydocker/tomcat8/jp-employment/webapps/'
|
|
|
- sshPut remote: sshServer, from: 'web-1.0.0.war', into: targetFolder
|
|
|
- sshCommand remote: sshServer, command: 'rm -rf ${targetFolder}/'
|
|
|
- sshCommand remote: sshServer, command: 'unzip ${targetFolder}/web-1.0.0.war -D jp-employment-server'
|
|
|
+ //更新 lib
|
|
|
+ dir("${env.WORKSPACE}/code/web/target/web-1.0.0/WEB-INF/lib"){
|
|
|
+ sshPut remote: sshServer, from: "common-1.0.0.jar", into: "${targetFolder}/${appName}-server/WEB-INF/lib"
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- def appName = 'demo1'
|
|
|
- sshCommand remote: sshServer, command: "docker stop $appName"
|
|
|
- sshCommand remote: sshServer, command: "docker rm $appName"
|
|
|
- sshCommand remote: sshServer, command: "docker run --name $appName -p 9091:80 -d $imageName"
|
|
|
+ sshCommand remote: sshServer, command: "docker start ${appName}"
|
|
|
}
|
|
|
}
|
|
|
}
|