mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-26 17:21:53 +08:00
!38 添加 Jenkinsfile;用于支持Jenkins的部署
Merge pull request !38 from weir/devops
This commit is contained in:
commit
2bcc55053b
60
Jenkinsfile
vendored
Normal file
60
Jenkinsfile
vendored
Normal file
@ -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'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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
|
||||
|
@ -65,7 +65,7 @@
|
||||
</root>
|
||||
</springProfile>
|
||||
<!-- 其它环境 -->
|
||||
<springProfile name="default">
|
||||
<springProfile name="dev,default">
|
||||
<root level="INFO">
|
||||
<appender-ref ref="STDOUT"/>
|
||||
<appender-ref ref="ASYNC"/>
|
||||
|
@ -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'
|
||||
|
||||
|
44
yudao-admin-ui/Jenkinsfile
vendored
Normal file
44
yudao-admin-ui/Jenkinsfile
vendored
Normal file
@ -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 考虑刷新缓存的问题
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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
|
||||
|
@ -41,7 +41,7 @@
|
||||
<podam.version>7.2.6.RELEASE</podam.version>
|
||||
<jedis-mock.version>0.1.16</jedis-mock.version>
|
||||
<!-- 工具类相关 -->
|
||||
<lombok.version>1.16.14</lombok.version>
|
||||
<lombok.version>1.18.12</lombok.version>
|
||||
<mapstruct.version>1.4.1.Final</mapstruct.version>
|
||||
<hutool.version>5.6.1</hutool.version>
|
||||
<easyexcel.verion>2.2.7</easyexcel.verion>
|
||||
|
Loading…
Reference in New Issue
Block a user