| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- pipeline {
- agent any
- environment {
- def appName = "jp-employment"
- def branch = "master"
- }
- tools {
- // Install the Maven version configured as "M3" and add it to the path.
- maven "M3"
- jdk "jdk8"
- }
- stages {
- stage('checkout') {
- steps {
- dir("${env.WORKSPACE}/code"){
- git branch: branch,credentialsId: 'cd13504d-d7eb-433f-be4b-4cbeedf0372d', url: 'http://47.92.161.104:10080/shuzhan/jp-employment-server.git'
- }
- }
- }
- 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'
- }
- }
- }
- stage('deploy') {
- steps {
- script {
- dir("${env.WORKSPACE}/code/web/target") {
- def host = '121.37.187.149'
- withCredentials([usernamePassword(credentialsId: '${host}',
- passwordVariable: 'pwd', usernameVariable: 'userName')]) {
- def sshServer = [:]
- sshServer.name = 'huawei server'
- sshServer.host ='${host}'
- sshServer.user = userName
- sshServer.password = pwd
- sshServer.allowAnyHosts= true
- sshCommand remote: sshServer, command: "docker stop ${appName}-server"
- 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'
- }
- 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"
- }
- }
- }
- }
- }
- }
- }
|