2021-07-25 01:24:50 +08:00
|
|
|
#!groovy
|
2021-07-23 00:26:40 +08:00
|
|
|
pipeline {
|
2021-07-25 01:24:50 +08:00
|
|
|
|
|
|
|
agent any
|
2021-07-23 00:26:40 +08:00
|
|
|
|
|
|
|
parameters {
|
2021-07-25 01:24:50 +08:00
|
|
|
string(name: 'TAG_NAME', defaultValue: '', description: '')
|
2021-07-23 00:26:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
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'
|
2021-07-25 01:24:50 +08:00
|
|
|
// 应用部署路径
|
|
|
|
APP_DEPLOY_BASE_DIR = '/media/pi/KINGTON/data/work/projects/'
|
2021-07-23 00:26:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
stages {
|
2021-07-25 01:24:50 +08:00
|
|
|
stage('检出') {
|
2021-07-23 00:26:40 +08:00
|
|
|
steps {
|
2021-07-25 01:24:50 +08:00
|
|
|
git url: "https://gitee.com/will-we/ruoyi-vue-pro.git",
|
|
|
|
branch: "devops"
|
2021-07-23 00:26:40 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-25 01:24:50 +08:00
|
|
|
stage('构建') {
|
2021-07-23 00:26:40 +08:00
|
|
|
steps {
|
2021-07-25 18:59:20 +08:00
|
|
|
// TODO 解决多环境链接、密码不同配置临时方案
|
|
|
|
sh 'if [ ! -d "' + "${env.HOME}" + '/resources" ];then\n' +
|
|
|
|
' echo "配置文件不存在无需修改"\n' +
|
|
|
|
'else\n' +
|
2021-07-25 19:43:31 +08:00
|
|
|
' cp -rf ' + "${env.HOME}" + '/resources/*.yaml ' + "${env.APP_NAME}" + '/src/main/resources\n' +
|
2021-07-25 18:59:20 +08:00
|
|
|
' echo "配置文件替换"\n' +
|
|
|
|
'fi'
|
2021-07-25 01:24:50 +08:00
|
|
|
sh 'mvn clean package -Dmaven.test.skip=true'
|
2021-07-23 00:26:40 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-25 01:24:50 +08:00
|
|
|
stage('部署') {
|
2021-07-23 00:26:40 +08:00
|
|
|
steps {
|
2021-07-25 01:24:50 +08:00
|
|
|
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'
|
2021-07-23 00:26:40 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|