Jenkinsfile 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. pipeline {
  2. agent any
  3. stages {
  4. stage('pull') {
  5. steps {
  6. checkout([$class: 'GitSCM', branches: [[name: "*/${branch}"]],
  7. doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [],
  8. userRemoteConfigs: [[credentialsId: '9bc5f661-86ed-446c-b0b3-e41b364a39a2',
  9. url: 'http://git.5kcrm.com/zhangzhiwei/wk_crm_single.git']]])
  10. echo '拉取代码成功'
  11. }
  12. }
  13. stage('build') {
  14. steps {
  15. script {
  16. def apps = "${project_name}".split(",")
  17. for (int i = 0; i < apps.size(); ++i) {
  18. sh label: '', script: "sh package.sh ${apps[i]}"
  19. echo " ${apps[i]} 打包成功"
  20. }
  21. }
  22. }
  23. }
  24. stage('deploy') {
  25. steps {
  26. echo 'deploy'
  27. withEnv(['JENKINS_NODE_COOKIE=dontkillme']) {
  28. script {
  29. def apps = "${project_name}".split(",")
  30. for (int i = 0; i < apps.size(); ++i) {
  31. sh label: '', script: "sh deploy.sh stop ${apps[i]}"
  32. sh label: '', script: "sh deploy.sh copy ${apps[i]}"
  33. sh label: '', script: "sh deploy.sh start ${apps[i]}"
  34. echo " ${apps[i]} 部署成功"
  35. }
  36. }
  37. }
  38. }
  39. }
  40. }
  41. }