二级部署

pull/2/head
weir 2021-07-27 21:42:08 +08:00
parent cb1fa73a4b
commit 91baf4185e
3 changed files with 11 additions and 6 deletions

View File

@ -3,4 +3,8 @@ ENV = 'production'
# 芋道管理系统/生产环境 # 芋道管理系统/生产环境
VUE_APP_BASE_API = '/prod-api' VUE_APP_BASE_API = '/prod-api'
# 根据服务器或域名修改
PUBLIC_PATH = 'http://you_ip.cn/yudao-admin/'
# 二级部署路径
VUE_APP_APP_NAME ='yudao-admin'

View File

@ -11,7 +11,7 @@ pipeline {
environment { environment {
APP_NAME = 'yudao-admin' APP_NAME = 'yudao-admin'
APP_PACKAGE='yudao-admin-ui' PROJECT_DIR='yudao-admin-ui'
NGINX_WORKDIR = '/home/pi/mydata/nginx/html/' NGINX_WORKDIR = '/home/pi/mydata/nginx/html/'
} }
@ -25,8 +25,8 @@ pipeline {
stage('构建') { stage('构建') {
steps { steps {
sh 'cnpm --prefix '+ "${env.APP_PACKAGE}" +' install' sh 'cnpm --prefix '+ "${env.PROJECT_DIR}" +' install'
sh 'cnpm --prefix '+ "${env.APP_PACKAGE}" +' run build:prod' sh 'cnpm --prefix '+ "${env.PROJECT_DIR}" +' run build:prod'
} }
} }
@ -34,9 +34,9 @@ pipeline {
steps { steps {
sh 'rm -f ' + "${env.APP_NAME}" + '/'+ "${env.APP_NAME}" + '.tar.gz' sh 'rm -f ' + "${env.APP_NAME}" + '/'+ "${env.APP_NAME}" + '.tar.gz'
sh 'mkdir -p ' + "${env.NGINX_WORKDIR}" + "${env.APP_NAME}" sh 'mkdir -p ' + "${env.NGINX_WORKDIR}" + "${env.APP_NAME}"
sh 'cp -rf ' + "${env.APP_PACKAGE}" + '/dist/. ' + "${env.NGINX_WORKDIR}" + "${env.APP_NAME}" sh 'cp -rf ' + "${env.PROJECT_DIR}" + '/dist/. ' + "${env.NGINX_WORKDIR}" + "${env.APP_NAME}"
sh 'tar -zcvf ' + "${env.APP_PACKAGE}" + '/'+ "${env.APP_PACKAGE}" + '.tar.gz ' + "${env.APP_PACKAGE}" + '/dist/' sh 'tar -zcvf ' + "${env.PROJECT_DIR}" + '/'+ "${env.PROJECT_DIR}" + '.tar.gz ' + "${env.PROJECT_DIR}" + '/dist/'
archiveArtifacts "${env.APP_PACKAGE}" + '/'+ "${env.APP_PACKAGE}" + '.tar.gz' archiveArtifacts "${env.PROJECT_DIR}" + '/'+ "${env.PROJECT_DIR}" + '.tar.gz'
//TODO 考虑刷新缓存的问题 //TODO 考虑刷新缓存的问题
} }
} }

View File

@ -122,6 +122,7 @@ export const constantRoutes = [
] ]
export default new Router({ export default new Router({
base: process.env.VUE_APP_APP_NAME ? process.env.VUE_APP_APP_NAME : "/",
mode: 'history', // 去掉url中的# mode: 'history', // 去掉url中的#
scrollBehavior: () => ({ y: 0 }), scrollBehavior: () => ({ y: 0 }),
routes: constantRoutes routes: constantRoutes