Jenkinsfile 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. def git_auth="d4b4c06c-7a45-4969-a06d-8363858e81cd"
  2. def git_url="http://10.68.0.122:3000/fanyijian/k8s.git"
  3. def jenkins_home="/var/jenkins_home/workspace/k8s"
  4. def xy_image="registry-vpc.cn-beijing.aliyuncs.com/xinyue-jenkins"
  5. def release="${BUILD_NUMBER}"
  6. def projectList = project_name.split(",")
  7. ansiColor('xterm') {
  8. node {
  9. stage('pull code') {
  10. echo "\u001B[32m############开始拉取代码############\u001B[0m"
  11. checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: "${git_auth}", url: "${git_url}"]]])
  12. }
  13. stage('build images') {
  14. for (int i = 0; i < projectList.length ; i++) {
  15. echo "\u001B[32m############正在build images,项目名为:${projectList[i]}############\u001B[0m"
  16. if ("${projectList[i]}" == "mchsrv" || "${projectList[i]}" == "sharebms2" || "${projectList[i]}" == "sharebms2-nginx" || "${projectList[i]}" == "sharesrv2") {
  17. sh "docker build -t ${xy_image}/${projectList[i]}:${release} -f ${jenkins_home}/share-v2/${projectList[i]}/Dockerfile ${jenkins_home}/share-v2/${projectList[i]}"
  18. } 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]}" == "登陆服务器-测试专用"){
  19. sh "docker build -t ${xy_image}/${projectList[i]}:${release} -f ${jenkins_home}/logonsvr/${projectList[i]}/Dockerfile ${jenkins_home}/logonsvr/${projectList[i]}"
  20. } else {
  21. sh "docker build -t ${xy_image}/${projectList[i]}:${release} -f ${jenkins_home}/${projectList[i]}/Dockerfile ${jenkins_home}/${projectList[i]}"
  22. }
  23. }
  24. }
  25. stage('push aliyuncs registry') {
  26. for (int i = 0; i < projectList.length ; i++) {
  27. echo "\u001B[32m############正在推送镜像,项目名为:${projectList[i]}############\u001B[0m"
  28. sh "docker push ${xy_image}/${projectList[i]}:${BUILD_NUMBER}"
  29. }
  30. }
  31. stage('push aliyuncs registry') {
  32. for (int i = 0; i < projectList.length ; i++) {
  33. sh "cd ${jenkins_home}/"
  34. sh "chmod +x ${jenkins_home}/jenkins.py"
  35. sh "python3 jenkins.py ${projectList[i]}"
  36. }
  37. }
  38. }
  39. }