jenkins.sh 567 B

123456789101112131415161718192021222324252627282930
  1. #!/bin/bash
  2. set -e # 如果构建失败,则退出,不能删除旧的包
  3. if [ "$#" -ne 1 ] ; then
  4. echo "Usage: $0 BUILD_ENV" >&2
  5. exit 1
  6. fi
  7. pwd
  8. echo “build env: $1”
  9. pwd
  10. yarn
  11. npm run build:$1
  12. mkdir -p ~/project/union-question/static-new/admin/temp
  13. cp -r dist ~/project/union-question/static-new/admin/temp
  14. cd ~/project/union-question/static-new/admin
  15. if [ -d "dist" ]; then
  16. currentTime=`date "+%Y%m%d%H%M%S"`
  17. echo "dist backup... $currentTime"
  18. tar cf admin-bak-$currentTime.tar.gz dist
  19. rm -rf dist/*
  20. fi
  21. mv temp/dist .
  22. rm -rf temp
  23. echo "ok..."