node { service_name = "tzy" registry = "registry.azure.ipangyou.com/poyi/${service_name}" k3s_opts = "--kubeconfig ~/k3s-prod.yaml" try{ stage('source code check out'){ echo "1. Check out project source ..." dir("projdir"){ //git branch: 'master', credentialsId: 'lingxz_git.ipangyou.com', url: 'https://git.ipangyou.com/poyi/tzy-admin.git' checkout([$class: 'GitSCM', branches: [[name: 'master']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'CleanBeforeCheckout'], [$class: 'CloneOption', depth: 1, noTags: false, reference: '', shallow: true, timeout: 240]], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'lingxz_git.ipangyou.com', url: 'https://git.ipangyou.com/poyi/tzy-admin.git']] ]) } dir("confdir") { git branch: 'master', credentialsId: 'lingxz_git.ipangyou.com', url: 'http://git.ipangyou.com/poyi/deployments.git' } } stage("maven build") { echo "2. Building java package ..." dir("projdir"){ sh '$MAVEN_HOME/bin/mvn clean package' } } stage("docker image build") { echo "3. Building docker image: $registry:$BUILD_NUMBER ..." dir("projdir"){ sh '''cat > Dockerfile< ${configmap_file}" sh "kubectl ${k3s_opts} apply -f ${configmap_file}" sh "kubectl ${k3s_opts} create configmap tzy-mock-environment --dry-run=client --from-env-file=./configmap-env -o yaml > ${configmap_env}" sh "kubectl ${k3s_opts} apply -f ${configmap_env}" } sh """cat > deployment.yml<