def git_auth="d4b4c06c-7a45-4969-a06d-8363858e81cd" def git_url="http://10.68.0.122:3000/fanyijian/k8s.git" def jenkins_home="/var/jenkins_home/workspace/k8s" def xy_image="registry-vpc.cn-beijing.aliyuncs.com/xinyue-jenkins" def release="${BUILD_NUMBER}" def projectList = project_name.split(",") ansiColor('xterm') { node { stage('pull code') { echo "\u001B[32m############开始拉取代码############\u001B[0m" checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: "${git_auth}", url: "${git_url}"]]]) } stage('build images') { for (int i = 0; i < projectList.length ; i++) { echo "\u001B[32m############正在build images,项目名为:${projectList[i]}############\u001B[0m" if ("${projectList[i]}" == "mchsrv" || "${projectList[i]}" == "sharebms2" || "${projectList[i]}" == "sharebms2-nginx" || "${projectList[i]}" == "sharesrv2") { sh "docker build -t ${xy_image}/${projectList[i]}:${release} -f ${jenkins_home}/share-v2/${projectList[i]}/Dockerfile ${jenkins_home}/share-v2/${projectList[i]}" } else if ("${projectList[i]}" == "login-app-jl" || "${projectList[i]}" == "login-app-lj" || "${projectList[i]}" == "login-app-ln" || "${projectList[i]}" == "login-mp" ||"${projectList[i]}" == "login-mp" ||"${projectList[i]}" == "login-mp-gf" || "${projectList[i]}" == "login-mp-intl" || "${projectList[i]}" == "login-websocket" || "${projectList[i]}" == "login-websocket-gf" || "${projectList[i]}" == "登陆服务器-提审" || "${projectList[i]}" == "登陆服务器-测试专用"){ sh "docker build -t ${xy_image}/${projectList[i]}:${release} -f ${jenkins_home}/logonsvr/${projectList[i]}/Dockerfile ${jenkins_home}/logonsvr/${projectList[i]}" } else { sh "docker build -t ${xy_image}/${projectList[i]}:${release} -f ${jenkins_home}/${projectList[i]}/Dockerfile ${jenkins_home}/${projectList[i]}" } } } stage('push aliyuncs registry') { for (int i = 0; i < projectList.length ; i++) { echo "\u001B[32m############正在推送镜像,项目名为:${projectList[i]}############\u001B[0m" sh "docker push ${xy_image}/${projectList[i]}:${BUILD_NUMBER}" } } stage('push aliyuncs registry') { for (int i = 0; i < projectList.length ; i++) { sh "cd ${jenkins_home}/" sh "chmod +x ${jenkins_home}/jenkins.py" sh "python3 jenkins.py ${projectList[i]}" } } } }