build.jenkins 4.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. pipeline {
  2. agent any
  3. stages {
  4. stage('prepare-framework') {
  5. steps {
  6. //sh 'if [ ! -d framework ]; then mkdir -p framework; fi && cd framework'
  7. echo "crowd-service private cloud [framework] preparing..."
  8. git branch: 'private-release-v2021', credentialsId: 'jenkins_git_com', url: 'ssh://git@git.mooctest.com:1022/crowd-2019/crowd-test-service-private-cloud.git'
  9. sh 'pwd && ls -al'
  10. sh 'chmod -R 777 ./crowd-service/TestFileSystem/'
  11. }
  12. }
  13. stage('cofotest-backend-job') {
  14. //后端构建
  15. steps{
  16. echo "crowd-service private cloud [backend] building..."
  17. //sh 'docker rmi $(docker images --filter=reference="crowd-backend" -q)'
  18. build job: '构建-群智项目后端-私有云环境', quietPeriod: 0
  19. echo "copy [backend image] to ./crowd-service/entity "
  20. sh 'cp ../构建-群智项目后端-私有云环境/crowd-backend.tar ./crowd-service/entity/'
  21. }
  22. }
  23. stage('cofotest-frontend-job') {
  24. //前端构建
  25. steps{
  26. echo "crowd-service private cloud [frontend] building..."
  27. //sh 'docker rmi $(docker images --filter=reference="crowd-frontend" -q)'
  28. build job: '构建-群智项目前端-私有云环境', quietPeriod: 0
  29. echo "copy [fronend image] to ./crowd-service/ ..."
  30. sh 'cp -r ../构建-群智项目前端-私有云环境/crowd-frontend.tar ./crowd-service/entity/'
  31. }
  32. }
  33. stage('cofotest-user-job') {
  34. //后端构建
  35. steps{
  36. echo "crowd-service private cloud [user] building..."
  37. //sh 'docker rmi $(docker images --filter=reference="crowd-user" -q)'
  38. build job: '构建-群智用户服务-私有云环境', quietPeriod: 0
  39. echo "copy [user image] to ./crowd-service/entity "
  40. sh 'cp ../构建-群智用户服务-私有云环境/crowd-user.tar ./crowd-service/entity/'
  41. }
  42. }
  43. stage('cofotest-mysql-job') {
  44. steps{
  45. echo 'cofotest db build'
  46. //sh 'docker rmi $(docker images --filter=reference="crowd-mysql" -q)'
  47. sh 'cd ./crowd-service/private-docker/mysql/ && docker build -t crowd-mysql .'
  48. sh 'docker save -o ./crowd-service/entity/crowd-mysql.tar crowd-mysql && ls -sl ./crowd-service/entity/'
  49. }
  50. }
  51. stage('cofotest-redis-job') {
  52. steps{
  53. echo 'redis docker build'
  54. //sh 'docker rmi $(docker images --filter=reference="crowd-redis" -q)'
  55. sh 'docker pull redis:latest'
  56. sh 'docker tag redis:latest crowd-redis'
  57. sh 'docker save -o ./crowd-service/entity/crowd-redis.tar crowd-redis && ls -sl ./crowd-service/entity/'
  58. }
  59. }
  60. stage('zip-job') {
  61. //压缩部署环境
  62. steps{
  63. echo 'zip private crowd-service'
  64. sh "zip -r private-crowd-service.zip ./crowd-service/"
  65. echo '看一下private-crowd-service.zip的大小'
  66. sh "ls -alh"
  67. }
  68. }
  69. stage('upload-job') {
  70. //上传到oss
  71. steps{
  72. echo 'upload private crowd-service'
  73. sh 'echo v${BUILD_NUMBER} >> private_crowd_service.txt'
  74. sh 'env LANG=en_US.UTF-8 date'
  75. // sh "env LANG=en_US.UTF-8 /bin/bash ./shell/oss.sh put private_crowd_service.txt private-cloud/crowd-test-service/private_crowd_service.txt"
  76. sh "env LANG=en_US.UTF-8 /bin/bash ./shell/oss.sh put private-crowd-service.zip private-cloud/crowd-test-service/private-crowd-service.v${BUILD_NUMBER}.zip"
  77. }
  78. }
  79. }
  80. post {
  81. // 后续的清理工作
  82. always {
  83. echo "试一下post"
  84. }
  85. success {
  86. // build job: '私有云自动化部署', quietPeriod: 2
  87. echo "success"
  88. }
  89. }
  90. }