diff --git a/Jenkinsfile b/Jenkinsfile index fc9b54f28033c31706829582651aa7ee03ac0fbe..ad09b34fbcf983c3449f71ffca1b9fb80e465044 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,38 +1,11 @@ node{ stage('Git Checkout'){ - checkout([$class: 'GitSCM', branches: [[name: '$Branches']], doGenerateSubmoduleConfigurations: false, extensions: [], gitTool: 'Default', submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'a97e0ce1-814b-4e7d-832a-4ac3eed72506', url: 'git@gitlab.schbrain.com:schbrain/backend/kp/kp-datav.git']]]) + checkout([$class: 'GitSCM', branches: [[name: '$Branches']], doGenerateSubmoduleConfigurations: false, extensions: [], gitTool: 'Default', submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'a97e0ce1-814b-4e7d-832a-4ac3eed72506', url: 'git@gitlab.schbrain.com:zhangdongdong/test.git']]]) } stage('Maven Build'){ sh "/var/jenkins_home/tools/apache-maven-3.6.3/bin/mvn clean -U package -Dversion=${version} -Dmaven.test.skip=true -P${profiles}" } - stage('Build & Push Image'){ - sh ''' - Registry=registry-vpc.cn-hangzhou.aliyuncs.com - ProjectName=$Registry/schbrain/kp-datav - docker build -t $ProjectName:${version} --build-arg APP_NAME_SRC=kp-datav-web-${version}.jar -f Dockerfile . - docker push $ProjectName:${version} - docker rmi $ProjectName:${version} - ''' - } - stage('Deploy to K8S'){ - if (profiles == 'dev') { - echo '接下来进行开发环境下项目的发布...' - sh ''' - sed -i "/image/{s/latest/${version}/}" b-k8s-deploy-dev.yaml - sed -i "/profiles/{s/profiles/${profiles}/}" b-k8s-deploy-dev.yaml - kubectl apply -f b-k8s-deploy-dev.yaml - ''' - } - if (profiles == 'prod') { - echo '接下来进行生产环境下项目的发布...' - sh ''' - sed -i "/image/{s/latest/${version}/}" b-k8s-deploy-prod.yaml - sed -i "/profiles/{s/profiles/${profiles}/}" b-k8s-deploy-prod.yaml - ~/kubectl --kubeconfig ~/.kube/config.prod apply -f b-k8s-deploy-${profiles}.yaml - ''' - } - } stage ('Post-Build') { script { currentBuild.description = "${version} - ${Branches}"