更改构建脚本

This commit is contained in:
zhouxiunai
2020-08-28 16:29:02 +08:00
parent 6179ea0ea2
commit 67b47ce3e0
2 changed files with 4 additions and 55 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
FROM 130.120.3.193/library/alpine-oraclejdk8:slim FROM reg.int.it2000.com.cn/com.gzzn.library/alpine-oraclejdk8:slim
MAINTAINER xiunai78 <154707516@qq.com> MAINTAINER xiunai78 <154707516@qq.com>
# Add the service itself # Add the service itself
+3 -54
View File
@@ -11,12 +11,11 @@ pipeline {
environment { environment {
credentialsId = 'e41b57a4-436a-4617-817c-9e3f25a8a47f' credentialsId = 'e41b57a4-436a-4617-817c-9e3f25a8a47f'
deployName = 'airport-dev' deployName = 'airport-dev'
deployHost = '130.120.3.231' deployHost = '130.120.3.15'
mailto = '154707516@qq.com' mailto = '154707516@qq.com'
dockerProtocol = "http" dockerProtocol = "https"
dockerRegistry = '130.120.3.193' dockerRegistry = 'reg.int.it2000.com.cn'
containerName="msgexchangeapi" containerName="msgexchangeapi"
export=95
GROUP = readMavenPom().getGroupId() GROUP = readMavenPom().getGroupId()
ARTIFACTID = readMavenPom().getArtifactId() ARTIFACTID = readMavenPom().getArtifactId()
@@ -48,55 +47,5 @@ pipeline {
} }
} }
stage('deploy') {
steps {
withCredentials([sshUserPrivateKey(credentialsId: "${env.credentialsId}", keyFileVariable: 'kfIdentity', passphraseVariable: 'pVariable', usernameVariable: 'userName')]) {
sshCommand(remote: [ name: "${env.deployName}" ,host: "${env.deployHost}" ,allowAnyHosts: true,user: "${userName}",identityFile: "${kfIdentity}" ] ,
command: "docker stop ${env.containerName}",sudo: true ,failOnError: false)
sshCommand(remote: [ name: "${env.deployName}" ,host: "${env.deployHost}" ,allowAnyHosts: true,user: "${userName}",identityFile: "${kfIdentity}" ] ,
command: "docker rm ${env.containerName}",sudo: true ,failOnError: false)
sshCommand(remote: [ name: "${env.deployName}" ,host: "${env.deployHost}" ,allowAnyHosts: true,user: "${userName}",identityFile: "${kfIdentity}" ] ,
command: "docker rmi ${env.dockerRegistry}/${env.GROUP}/${env.ARTIFACTID}:${env.VERSION}",sudo: true ,failOnError: false)
sshCommand(remote: [ name: "${env.deployName}" ,host: "${env.deployHost}" ,allowAnyHosts: true,user: "${userName}",identityFile: "${kfIdentity}" ] ,
command: "docker run -d -p ${env.export}:8080 --name ${env.containerName} ${env.dockerRegistry}/${env.GROUP}/${env.ARTIFACTID}:${env.VERSION}",sudo: true ,failOnError: true)
}
}
}
}
post {
success {
emailext (
subject: "'${env.JOB_NAME} [${env.BUILD_NUMBER}]' 更新正常",
body: """
详情:
SUCCESSFUL: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'
状态:${env.JOB_NAME} jenkins 更新运行正常
URL ${env.BUILD_URL}
项目名称 ${env.JOB_NAME}
项目更新进度:${env.BUILD_NUMBER}
""",
to: "${env.mailto}",
recipientProviders: [[$class: 'DevelopersRecipientProvider']]
)
}
failure {
emailext (
subject: "'${env.JOB_NAME} [${env.BUILD_NUMBER}]' 更新失败",
body: """
详情:
FAILED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'
状态:${env.JOB_NAME} jenkins 运行失败
URL ${env.BUILD_URL}
项目名称 ${env.JOB_NAME}
项目更新进度:${env.BUILD_NUMBER}
""",
to: "${env.mailto}",
recipientProviders: [[$class: 'DevelopersRecipientProvider']]
)
}
} }
} }