Jenkinsfile 1.4 KB

123456789101112131415161718192021222324252627282930
  1. def git_auth="d4b4c06c-7a45-4969-a06d-8363858e81cd"
  2. def git_url="http://10.68.0.122:3000/mengqingchuang/k8swebapi.git"
  3. def jenkins_home="/var/jenkins_home/workspace/k8swebapi/"
  4. def xy_image="registry-vpc.cn-beijing.aliyuncs.com/xinyue/"
  5. def release="${BUILD_NUMBER}"
  6. def projectList = project_name.split(",")
  7. node {
  8. stage('pull code') {
  9. checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: "${git_auth}", url: "${git_url}"]]])}
  10. stage('build images') {
  11. for (int i = 0; i < projectList.length ; i++) {
  12. echo "正在build images,项目名为:${projectList[i]}"
  13. sh "docker build -t ${xy_image}${projectList[i]}:${release} -f ${jenkins_home}${projectList[i]}/Dockerfile ${jenkins_home}${projectList[i]}"
  14. }
  15. }
  16. stage('push aliyuncs registry') {
  17. for (int i = 0; i < projectList.length ; i++) {
  18. echo "正在推送镜像,项目名为:${projectList[i]} "
  19. sh "docker push ${xy_image}${projectList[i]}:${BUILD_NUMBER}"
  20. }
  21. }
  22. stage('push aliyuncs registry') {
  23. for (int i = 0; i < projectList.length ; i++) {
  24. sh "cd ${jenkins_home}"
  25. sh "chmod +x ${jenkins_home}jenkins.py"
  26. sh "python3 jenkins.py ${projectList[i]}"
  27. }
  28. }
  29. }