deploy.sh 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/bin/bash
  2. #该脚本为私有化脚本,打包成内含网页的product-report-starter放在内网私服
  3. echo 'choose deploy type [1/2]'
  4. echo '1:deploy snapshot'
  5. echo '2:deploy release'
  6. read choose
  7. #判断node.js mvn是否存在
  8. command -v npm >/dev/null 2>&1 || { echo >&2 "I require node.js v14.16.0+ but it's not installed. Aborting."; sleep 5; exit 1; }
  9. command -v mvn >/dev/null 2>&1 || { echo >&2 "I require maven 3.5 + but it's not installed. Aborting."; sleep 5; exit 1; }
  10. cd `dirname $0`
  11. BuildDir=`pwd` #工程根目录
  12. #重置pom和index.js
  13. cat $BuildDir/build/index.js > $BuildDir/report-ui/config/index.js
  14. cat $BuildDir/build/pom.xml > $BuildDir/report-core/pom.xml
  15. echo "build web"
  16. cd $BuildDir/report-ui
  17. rm -rf dist
  18. npm install >/dev/null 2>&1
  19. npm run build:prod
  20. echo "publish web to springboot src/main/resources/static"
  21. rm -rf $BuildDir/report-core/src/main/resources/static
  22. mkdir -p $BuildDir/report-core/src/main/resources/static
  23. mv $BuildDir/report-ui/dist/* $BuildDir/report-core/src/main/resources/static/
  24. echo "build springboot"
  25. cd $BuildDir/report-core
  26. if [ $choose = '2' ]; then
  27. mvn clean deploy -DskipTests -DaltDeploymentRepository=nexus-releases::default::http://10.108.10.53:8081/repository/maven-releases
  28. else
  29. mvn clean deploy -DskipTests -DaltDeploymentRepository=nexus-snapshots::default::http://10.108.10.53:8081/repository/maven-snapshots
  30. fi
  31. rm -rf $BuildDir/report-core/src/main/resources/static
  32. git reset --hard