pipeline { agent any stages { stage('prepare-framework') { steps { //sh 'if [ ! -d framework ]; then mkdir -p framework; fi && cd framework' echo "crowd-service private cloud [framework] preparing..." git branch: 'private-release-v2021', credentialsId: 'jenkins_git_com', url: 'ssh://git@git.mooctest.com:1022/crowd-2019/crowd-test-service-private-cloud.git' sh 'pwd && ls -al' sh 'chmod -R 777 ./crowd-service/TestFileSystem/' } } stage('cofotest-backend-job') { //后端构建 steps{ echo "crowd-service private cloud [backend] building..." //sh 'docker rmi $(docker images --filter=reference="crowd-backend" -q)' build job: '构建-群智项目后端-私有云环境', quietPeriod: 0 echo "copy [backend image] to ./crowd-service/entity " sh 'cp ../构建-群智项目后端-私有云环境/crowd-backend.tar ./crowd-service/entity/' } } stage('cofotest-frontend-job') { //前端构建 steps{ echo "crowd-service private cloud [frontend] building..." //sh 'docker rmi $(docker images --filter=reference="crowd-frontend" -q)' build job: '构建-群智项目前端-私有云环境', quietPeriod: 0 echo "copy [fronend image] to ./crowd-service/ ..." sh 'cp -r ../构建-群智项目前端-私有云环境/crowd-frontend.tar ./crowd-service/entity/' } } stage('cofotest-user-job') { //后端构建 steps{ echo "crowd-service private cloud [user] building..." //sh 'docker rmi $(docker images --filter=reference="crowd-user" -q)' build job: '构建-群智用户服务-私有云环境', quietPeriod: 0 echo "copy [user image] to ./crowd-service/entity " sh 'cp ../构建-群智用户服务-私有云环境/crowd-user.tar ./crowd-service/entity/' } } stage('cofotest-mysql-job') { steps{ echo 'cofotest db build' //sh 'docker rmi $(docker images --filter=reference="crowd-mysql" -q)' sh 'cd ./crowd-service/private-docker/mysql/ && docker build -t crowd-mysql .' sh 'docker save -o ./crowd-service/entity/crowd-mysql.tar crowd-mysql && ls -sl ./crowd-service/entity/' } } stage('cofotest-redis-job') { steps{ echo 'redis docker build' //sh 'docker rmi $(docker images --filter=reference="crowd-redis" -q)' sh 'docker pull redis:latest' sh 'docker tag redis:latest crowd-redis' sh 'docker save -o ./crowd-service/entity/crowd-redis.tar crowd-redis && ls -sl ./crowd-service/entity/' } } stage('zip-job') { //压缩部署环境 steps{ echo 'zip private crowd-service' sh "zip -r private-crowd-service.zip ./crowd-service/" echo '看一下private-crowd-service.zip的大小' sh "ls -alh" } } stage('upload-job') { //上传到oss steps{ echo 'upload private crowd-service' sh 'echo v${BUILD_NUMBER} >> private_crowd_service.txt' sh 'env LANG=en_US.UTF-8 date' // 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" 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" } } } post { // 后续的清理工作 always { echo "试一下post" } success { // build job: '私有云自动化部署', quietPeriod: 2 echo "success" } } }