From 812bbe424f1cf6dce395cf2bd3c48e998a7aa6aa Mon Sep 17 00:00:00 2001 From: bpa <1370533105@qq.com> Date: Mon, 19 Aug 2024 02:08:26 +0000 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20'Jenkinsfile'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Jenkinsfile | 50 ++++++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 4a6ca4d..2c5ada7 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,12 +1,19 @@ +def getHost(){ + def remote = [:] + remote.name = 'eip' + remote.host = '10.2.1.254' + remote.user = 'root' + remote.port = 22 + remote.password = 'bpaadmin' + remote.allowAnyHosts = true + return remote +} + + pipeline{ agent any parameters { - choice( - description: 'pztjwebi:开发环境1', - name: 'environment', - choices: ['pztj'] - ) choice( description: '前端or后端', @@ -26,12 +33,6 @@ pipeline{ choices: ['master'] ) - string( - name: 'tag', - defaultValue: '', - description: '版本tag' - ) - } stages @@ -83,11 +84,11 @@ pipeline{ if(params.projectqh=='backend') { sh "cp -r backend/* ./" - sh "docker build -f backend/dockerfile -t 10.2.1.24:10242/bpa/pztjapi:${build_tag} ." + sh "docker build -f backend/dockerfile -t 10.2.1.24:10242/bpa/finalapi:${build_tag} ." } else if(params.projectqh=='frontend') { - sh "docker build -f frontend/dockerfile -t 10.2.1.24:10242/bpa/pztjweb:${build_tag} ." + sh "docker build -f frontend/dockerfile -t 10.2.1.24:10242/bpa/finalweb:${build_tag} ." } } @@ -106,12 +107,12 @@ pipeline{ { if(params.projectqh=='backend') { - sh "docker push 10.2.1.24:10242/bpa/pztjapi:${build_tag}" + sh "docker push 10.2.1.24:10242/bpa/finalapi:${build_tag}" } else if(params.projectqh=='frontend') { - sh "docker push 10.2.1.24:10242/bpa/pztjweb:${build_tag}" + sh "docker push 10.2.1.24:10242/bpa/finalweb:${build_tag}" } } @@ -133,18 +134,19 @@ pipeline{ // } if(params.projectqh=='backend') { - - sh "sed -i 's//${build_tag}/' k8s_pztjapi.yaml" - sh "sed -i 's//${env.BRANCH_NAME}/' k8s_pztjapi.yaml" - sh "sed -i 's//${params.environment}/' k8s_pztjapi.yaml" - sh "kubectl apply -f k8s_pztjapi.yaml --record" + server = getHost() + sshCommand remote: server, command: """ + /home/finalmes/api/install.sh ${build_tag} + """ + } else if(params.projectqh=='frontend') { - sh "sed -i 's//${build_tag}/' k8s_pztjweb.yaml" - sh "sed -i 's//${env.BRANCH_NAME}/' k8s_pztjweb.yaml" - sh "sed -i 's//${params.environment}/' k8s_pztjweb.yaml" - sh "kubectl apply -f k8s_pztjweb.yaml --record" + server = getHost() + sshCommand remote: server, command: """ + /home/finalmes/web/install.sh ${build_tag} + """ + } }