diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 000000000..38789a064 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,60 @@ +#!groovy +pipeline { + + agent any + + parameters { + string(name: 'TAG_NAME', defaultValue: '', description: '') + } + + environment { + // DockerHub 凭证 ID(登录您的 DockerHub) + DOCKER_CREDENTIAL_ID = 'dockerhub-id' + // GitHub 凭证 ID (推送 tag 到 GitHub 仓库) + GITHUB_CREDENTIAL_ID = 'github-id' + // kubeconfig 凭证 ID (访问接入正在运行的 Kubernetes 集群) + KUBECONFIG_CREDENTIAL_ID = 'demo-kubeconfig' + // 镜像的推送 + REGISTRY = 'docker.io' + // DockerHub 账号名 + DOCKERHUB_NAMESPACE = 'docker_username' + // GitHub 账号名 + GITHUB_ACCOUNT = 'https://gitee.com/zhijiantianya/ruoyi-vue-pro' + // 应用名称 + APP_NAME = 'yudao-admin-server' + // 应用部署路径 + APP_DEPLOY_BASE_DIR = '/media/pi/KINGTON/data/work/projects/' + } + + stages { + stage('检出') { + steps { + git url: "https://gitee.com/will-we/ruoyi-vue-pro.git", + branch: "devops" + } + } + + stage('构建') { + steps { + // TODO 解决多环境链接、密码不同配置临时方案 + sh 'if [ ! -d "' + "${env.HOME}" + '/resources" ];then\n' + + ' echo "配置文件不存在无需修改"\n' + + 'else\n' + + ' cp -rf ' + "${env.HOME}" + '/resources/*.yaml ' + "${env.APP_NAME}" + '/src/main/resources\n' + + ' echo "配置文件替换"\n' + + 'fi' + sh 'mvn clean package -Dmaven.test.skip=true' + } + } + + stage('部署') { + steps { + sh 'cp -f ' + ' bin/deploy.sh ' + "${env.APP_DEPLOY_BASE_DIR}" + "${env.APP_NAME}" + sh 'cp -f ' + "${env.APP_NAME}" + '/target/*.jar ' + "${env.APP_DEPLOY_BASE_DIR}" + "${env.APP_NAME}" +'/build/' + archiveArtifacts "${env.APP_NAME}" + '/target/*.jar' + sh 'chmod +x ' + "${env.APP_DEPLOY_BASE_DIR}" + "${env.APP_NAME}" + '/deploy.sh' + sh 'bash ' + "${env.APP_DEPLOY_BASE_DIR}" + "${env.APP_NAME}" + '/deploy.sh' + } + } + } +} \ No newline at end of file diff --git a/bin/deploy.sh b/bin/deploy.sh index ce295c7c1..2a48893a8 100644 --- a/bin/deploy.sh +++ b/bin/deploy.sh @@ -8,7 +8,7 @@ set -e DATE=$(date +%Y%m%d%H%M) # 基础路径 -BASE_PATH=/work/projects/yudao-admin-server +BASE_PATH=/media/pi/KINGTON/data/work/projects/yudao-admin-server # 编译后 jar 的地址。部署时,Jenkins 会上传 jar 包到该目录下 SOURCE_PATH=$BASE_PATH/build # 服务名称。同时约定部署服务的 jar 包名字也为它。 @@ -24,11 +24,11 @@ HEAP_ERROR_PATH=$BASE_PATH/heapError JAVA_OPS="-Xms512m -Xmx512m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=$HEAP_ERROR_PATH" # SkyWalking Agent 配置 -export SW_AGENT_NAME=$SERVER_NAME -export SW_AGENT_COLLECTOR_BACKEND_SERVICES=192.168.0.84:11800 -export SW_GRPC_LOG_SERVER_HOST=192.168.0.84 -export SW_AGENT_TRACE_IGNORE_PATH="Redisson/PING,/actuator/**,/admin/**" -export JAVA_AGENT=-javaagent:/work/skywalking/apache-skywalking-apm-bin/agent/skywalking-agent.jar +#export SW_AGENT_NAME=$SERVER_NAME +#export SW_AGENT_COLLECTOR_BACKEND_SERVICES=192.168.0.84:11800 +#export SW_GRPC_LOG_SERVER_HOST=192.168.0.84 +#export SW_AGENT_TRACE_IGNORE_PATH="Redisson/PING,/actuator/**,/admin/**" +#export JAVA_AGENT=-javaagent:/work/skywalking/apache-skywalking-apm-bin/agent/skywalking-agent.jar # 备份 function backup() { @@ -159,7 +159,7 @@ function deploy() { # 启动 Java 服务 start # 健康检查 - healthCheck +# healthCheck } deploy diff --git a/yudao-admin-server/src/main/resources/logback-spring.xml b/yudao-admin-server/src/main/resources/logback-spring.xml index 5bc181fd2..8c85ad493 100644 --- a/yudao-admin-server/src/main/resources/logback-spring.xml +++ b/yudao-admin-server/src/main/resources/logback-spring.xml @@ -65,7 +65,7 @@ - + diff --git a/yudao-admin-ui/.env.production b/yudao-admin-ui/.env.production index e00052eb6..5c64ef413 100644 --- a/yudao-admin-ui/.env.production +++ b/yudao-admin-ui/.env.production @@ -3,3 +3,8 @@ ENV = 'production' # 芋道管理系统/生产环境 VUE_APP_BASE_API = '/prod-api' +# 根据服务器或域名修改 +PUBLIC_PATH = 'http://you_ip.cn/yudao-admin/' +# 二级部署路径 +VUE_APP_APP_NAME ='yudao-admin' + diff --git a/yudao-admin-ui/Jenkinsfile b/yudao-admin-ui/Jenkinsfile new file mode 100644 index 000000000..65d18d449 --- /dev/null +++ b/yudao-admin-ui/Jenkinsfile @@ -0,0 +1,44 @@ +#!groovy +pipeline { + + agent any + + tools { nodejs "nodejs" } + + parameters { + string(name: 'TAG_NAME', defaultValue: '', description: '') + } + + environment { + APP_NAME = 'yudao-admin' + PROJECT_DIR='yudao-admin-ui' + NGINX_WORKDIR = '/home/pi/mydata/nginx/html/' + } + + stages { + stage('检出') { + steps { + git url: "https://gitee.com/will-we/ruoyi-vue-pro.git", + branch: "devops" + } + } + + stage('构建') { + steps { + sh 'cnpm --prefix '+ "${env.PROJECT_DIR}" +' install' + sh 'cnpm --prefix '+ "${env.PROJECT_DIR}" +' run build:prod' + } + } + + stage('部署') { + steps { + sh 'rm -f ' + "${env.APP_NAME}" + '/'+ "${env.APP_NAME}" + '.tar.gz' + sh 'mkdir -p ' + "${env.NGINX_WORKDIR}" + "${env.APP_NAME}" + sh 'cp -rf ' + "${env.PROJECT_DIR}" + '/dist/. ' + "${env.NGINX_WORKDIR}" + "${env.APP_NAME}" + sh 'tar -zcvf ' + "${env.PROJECT_DIR}" + '/'+ "${env.PROJECT_DIR}" + '.tar.gz ' + "${env.PROJECT_DIR}" + '/dist/' + archiveArtifacts "${env.PROJECT_DIR}" + '/'+ "${env.PROJECT_DIR}" + '.tar.gz' + //TODO 考虑刷新缓存的问题 + } + } + } +} diff --git a/yudao-admin-ui/src/router/index.js b/yudao-admin-ui/src/router/index.js index a4f676306..82a304551 100644 --- a/yudao-admin-ui/src/router/index.js +++ b/yudao-admin-ui/src/router/index.js @@ -122,6 +122,7 @@ export const constantRoutes = [ ] export default new Router({ + base: process.env.VUE_APP_APP_NAME ? process.env.VUE_APP_APP_NAME : "/", mode: 'history', // 去掉url中的# scrollBehavior: () => ({ y: 0 }), routes: constantRoutes diff --git a/yudao-dependencies/pom.xml b/yudao-dependencies/pom.xml index 5556b6be2..42adcdf8a 100644 --- a/yudao-dependencies/pom.xml +++ b/yudao-dependencies/pom.xml @@ -41,7 +41,7 @@ 7.2.6.RELEASE 0.1.16 - 1.16.14 + 1.18.12 1.4.1.Final 5.6.1 2.2.7