Jenkinsfile 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!groovy
  2. pipeline {
  3. agent any
  4. tools { nodejs "nodejs" }
  5. parameters {
  6. string(name: 'TAG_NAME', defaultValue: '', description: '')
  7. }
  8. environment {
  9. APP_NAME = 'patrol-admin'
  10. PROJECT_DIR='patrol-admin-ui'
  11. NGINX_WORKDIR = '/home/pi/mydata/nginx/html/'
  12. }
  13. stages {
  14. stage('检出') {
  15. steps {
  16. git url: "https://gitee.com/will-we/ruoyi-vue-pro.git",
  17. branch: "devops"
  18. }
  19. }
  20. stage('构建') {
  21. steps {
  22. sh 'cnpm --prefix '+ "${env.PROJECT_DIR}" +' install'
  23. sh 'cnpm --prefix '+ "${env.PROJECT_DIR}" +' run build:prod'
  24. }
  25. }
  26. stage('部署') {
  27. steps {
  28. sh 'rm -f ' + "${env.APP_NAME}" + '/'+ "${env.APP_NAME}" + '.tar.gz'
  29. sh 'mkdir -p ' + "${env.NGINX_WORKDIR}" + "${env.APP_NAME}"
  30. sh 'cp -rf ' + "${env.PROJECT_DIR}" + '/dist/. ' + "${env.NGINX_WORKDIR}" + "${env.APP_NAME}"
  31. sh 'tar -zcvf ' + "${env.PROJECT_DIR}" + '/'+ "${env.PROJECT_DIR}" + '.tar.gz ' + "${env.PROJECT_DIR}" + '/dist/'
  32. archiveArtifacts "${env.PROJECT_DIR}" + '/'+ "${env.PROJECT_DIR}" + '.tar.gz'
  33. //TODO 考虑刷新缓存的问题
  34. }
  35. }
  36. }
  37. }