pipeline{ agent any options { disableConcurrentBuilds() } parameters { string( name: 'BUILD_TIME', defaultValue: new Date().format("yyyy-MM-dd-HH-mm-ss", TimeZone.getTimeZone("Asia/Shanghai")), description: 'Build time in UTC' ) } triggers { pollSCM 'H/3 * * * * ' } stages{ stage("打包"){ steps{ withCredentials([usernamePassword(credentialsId: 'codeup_lihongjie0209', passwordVariable: 'p', usernameVariable: 'u')]) { sh "docker login -u ${u} -p ${p} registry.cn-beijing.aliyuncs.com" } sh "docker build . -t registry.cn-beijing.aliyuncs.com/lihongjie/coal:${env.BRANCH_NAME}-latest" sh "docker tag registry.cn-beijing.aliyuncs.com/lihongjie/coal:${env.BRANCH_NAME}-latest registry.cn-beijing.aliyuncs.com/lihongjie/coal:${env.BRANCH_NAME}-${params.BUILD_TIME}" sh "docker push registry.cn-beijing.aliyuncs.com/lihongjie/coal:${env.BRANCH_NAME}-latest" sh "docker push registry.cn-beijing.aliyuncs.com/lihongjie/coal:${env.BRANCH_NAME}-${params.BUILD_TIME}" } } // stage("重新部署"){ // // // steps{ // // sh "kubectl --kubeconfig=homelab.yaml apply -k k8s/${env.BRANCH_NAME}/" // sh "kubectl --kubeconfig=homelab.yaml rollout restart deployment/coal-api --namespace coal-${env.BRANCH_NAME}" // // // } // // } } }