1 Star 0 Fork 15.1K

user_5348805/RuoYi-Cloud

forked from 若依/RuoYi-Cloud 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Jenkinsfile 9.45 KB
一键复制 编辑 原始数据 按行查看 历史
李成均 提交于 2022-01-25 10:36 . dafd
pipeline {
agent {
node {
label 'maven'
}
}
stages {
stage('拉取代码') {
agent none
steps {
container('maven') {
git(url: 'https://gitee.com/fulinzhongguo/RuoYi-Cloud.git', credentialsId: 'gitee-id', branch: 'master', changelog: true, poll: false)
sh 'ls'
}
}
}
stage('打包构建') {
agent none
steps {
container('maven') {
sh '''ls
mvn clean package -Dmaven.test.skip=true sonar:sonar \
-Dsonar.projectKey=ruoyi \
-Dsonar.host.url=http://192.168.40.21:30108 \
-Dsonar.login=a127e637eb2f4899a29b5d2159126c79c8e699b9'''
sh 'ls ruoyi-modules/ruoyi-system/target/'
}
}
}
stage('构建镜像 & 上传镜像') {
parallel {
stage('ruoyi-system') {
agent none
steps {
container('maven') {
sh 'docker build -f ruoyi-modules/ruoyi-system/Dockerfile -t $REGISTRY/$DOCKERHUB_NAMESPACE/ruoyi-system:$BUILD_NUMBER ruoyi-modules/ruoyi-system/'
withCredentials([usernamePassword(credentialsId : 'dockerhub-id' ,usernameVariable : 'DOCKER_USERNAME' ,passwordVariable : 'DOCKER_PASSWORD' ,)]) {
sh 'echo "$DOCKER_PASSWORD" | docker login $REGISTRY -u "$DOCKER_USERNAME" --password-stdin'
sh 'docker images | grep ruoyi-system'
sh 'docker push $REGISTRY/$DOCKERHUB_NAMESPACE/ruoyi-system:$BUILD_NUMBER'
}
}
}
}
stage('ruoyi-job') {
agent none
steps {
container('maven') {
sh 'docker build -f ruoyi-modules/ruoyi-job/Dockerfile -t $REGISTRY/$DOCKERHUB_NAMESPACE/ruoyi-job:$BUILD_NUMBER ruoyi-modules/ruoyi-job/'
withCredentials([usernamePassword(credentialsId : 'dockerhub-id' ,usernameVariable : 'DOCKER_USERNAME' ,passwordVariable : 'DOCKER_PASSWORD' ,)]) {
sh 'echo "$DOCKER_PASSWORD" | docker login $REGISTRY -u "$DOCKER_USERNAME" --password-stdin'
sh 'docker images | grep ruoyi-job'
sh 'docker push $REGISTRY/$DOCKERHUB_NAMESPACE/ruoyi-job:$BUILD_NUMBER'
}
}
}
}
stage('ruoyi-gen') {
agent none
steps {
container('maven') {
sh 'docker build -f ruoyi-modules/ruoyi-gen/Dockerfile -t $REGISTRY/$DOCKERHUB_NAMESPACE/ruoyi-gen:$BUILD_NUMBER ruoyi-modules/ruoyi-gen/'
withCredentials([usernamePassword(credentialsId : 'dockerhub-id' ,usernameVariable : 'DOCKER_USERNAME' ,passwordVariable : 'DOCKER_PASSWORD' ,)]) {
sh 'echo "$DOCKER_PASSWORD" | docker login $REGISTRY -u "$DOCKER_USERNAME" --password-stdin'
sh 'docker images | grep ruoyi-gen'
sh 'docker push $REGISTRY/$DOCKERHUB_NAMESPACE/ruoyi-gen:$BUILD_NUMBER'
}
}
}
}
stage('ruoyi-file') {
agent none
steps {
container('maven') {
sh 'docker build -f ruoyi-modules/ruoyi-file/Dockerfile -t $REGISTRY/$DOCKERHUB_NAMESPACE/ruoyi-file:$BUILD_NUMBER ruoyi-modules/ruoyi-file/'
withCredentials([usernamePassword(credentialsId : 'dockerhub-id' ,usernameVariable : 'DOCKER_USERNAME' ,passwordVariable : 'DOCKER_PASSWORD' ,)]) {
sh 'echo "$DOCKER_PASSWORD" | docker login $REGISTRY -u "$DOCKER_USERNAME" --password-stdin'
sh 'docker images | grep ruoyi-file'
sh 'docker push $REGISTRY/$DOCKERHUB_NAMESPACE/ruoyi-file:$BUILD_NUMBER'
}
}
}
}
stage('ruoyi-monitor') {
agent none
steps {
container('maven') {
sh 'docker build -f ruoyi-visual/ruoyi-monitor/Dockerfile -t $REGISTRY/$DOCKERHUB_NAMESPACE/ruoyi-monitor:$BUILD_NUMBER ruoyi-visual/ruoyi-monitor/'
withCredentials([usernamePassword(credentialsId : 'dockerhub-id' ,usernameVariable : 'DOCKER_USERNAME' ,passwordVariable : 'DOCKER_PASSWORD' ,)]) {
sh 'echo "$DOCKER_PASSWORD" | docker login $REGISTRY -u "$DOCKER_USERNAME" --password-stdin'
sh 'docker images | grep ruoyi-monitor'
sh 'docker push $REGISTRY/$DOCKERHUB_NAMESPACE/ruoyi-monitor:$BUILD_NUMBER'
}
}
}
}
stage('ruoyi-auth') {
agent none
steps {
container('maven') {
sh 'docker build -f ruoyi-auth/Dockerfile -t $REGISTRY/$DOCKERHUB_NAMESPACE/ruoyi-auth:$BUILD_NUMBER ruoyi-auth/'
withCredentials([usernamePassword(credentialsId : 'dockerhub-id' ,usernameVariable : 'DOCKER_USERNAME' ,passwordVariable : 'DOCKER_PASSWORD' ,)]) {
sh 'echo "$DOCKER_PASSWORD" | docker login $REGISTRY -u "$DOCKER_USERNAME" --password-stdin'
sh 'docker images | grep ruoyi-auth'
sh 'docker push $REGISTRY/$DOCKERHUB_NAMESPACE/ruoyi-auth:$BUILD_NUMBER'
}
}
}
}
stage('ruoyi-gateway') {
agent none
steps {
container('maven') {
sh 'docker build -f ruoyi-gateway/Dockerfile -t $REGISTRY/$DOCKERHUB_NAMESPACE/ruoyi-gateway:$BUILD_NUMBER ruoyi-gateway/'
withCredentials([usernamePassword(credentialsId : 'dockerhub-id' ,usernameVariable : 'DOCKER_USERNAME' ,passwordVariable : 'DOCKER_PASSWORD' ,)]) {
sh 'echo "$DOCKER_PASSWORD" | docker login $REGISTRY -u "$DOCKER_USERNAME" --password-stdin'
sh 'docker images | grep ruoyi-gateway'
sh 'docker push $REGISTRY/$DOCKERHUB_NAMESPACE/ruoyi-gateway:$BUILD_NUMBER'
}
}
}
}
}
}
stage('default-3') {
parallel {
stage('部署 ruoyi-system') {
agent none
steps {
input(message: '''@admin
部署吗''', submitter: 'admin')
kubernetesDeploy(enableConfigSubstitution: true, deleteResource: false, kubeconfigId: 'demo-kubeconfig', configs: 'ruoyi-modules/ruoyi-system/deploy/**')
echo 'ruoyi-system 部署成功'
}
}
stage('部署 ruoyi-job') {
agent none
steps {
input(message: '''@admin
部署吗''', submitter: 'admin')
kubernetesDeploy(enableConfigSubstitution: true, deleteResource: false, kubeconfigId: 'demo-kubeconfig', configs: 'ruoyi-modules/ruoyi-job/deploy/**')
echo 'ruoyi-job 部署成功'
}
}
stage('部署 ruoyi-gen') {
agent none
steps {
input(message: '''@admin
部署吗''', submitter: 'admin')
kubernetesDeploy(enableConfigSubstitution: true, deleteResource: false, kubeconfigId: 'demo-kubeconfig', configs: 'ruoyi-modules/ruoyi-gen/deploy/**')
echo 'ruoyi-gen 部署成功'
}
}
stage('部署 ruoyi-file') {
agent none
steps {
input(message: '''@admin
部署吗''', submitter: 'admin')
kubernetesDeploy(enableConfigSubstitution: true, deleteResource: false, kubeconfigId: 'demo-kubeconfig', configs: 'ruoyi-modules/ruoyi-file/deploy/**')
echo 'ruoyi-file 部署成功'
}
}
stage('部署 ruoyi-monitor') {
agent none
steps {
input(message: '''@admin
部署吗''', submitter: 'admin')
kubernetesDeploy(enableConfigSubstitution: true, deleteResource: false, kubeconfigId: 'demo-kubeconfig', configs: 'ruoyi-visual/ruoyi-monitor/deploy/**')
echo 'ruoyi-monitor 部署成功'
}
}
stage('部署 ruoyi-auth') {
agent none
steps {
input(message: '''@admin
部署吗''', submitter: 'admin')
kubernetesDeploy(enableConfigSubstitution: true, deleteResource: false, kubeconfigId: 'demo-kubeconfig', configs: 'ruoyi-auth/deploy/**')
echo 'ruoyi-auth 部署成功'
}
}
stage('部署 ruoyi-gateway') {
agent none
steps {
input(message: '''@admin
部署吗''', submitter: 'admin')
kubernetesDeploy(enableConfigSubstitution: true, deleteResource: false, kubeconfigId: 'demo-kubeconfig', configs: 'ruoyi-gateway/deploy/**')
echo 'ruoyi-gateway 部署成功'
}
}
}
}
stage('发送邮件') {
agent none
steps {
mail(to: '755907724@qq.com', cc: 'fulinzhongguo@163.com', subject: "$APP_NAME 部署成功", body: "$APP_NAME - $BRANCH_NAME 分支 部署成功")
}
}
stage('是否要部署到生产环境') {
agent none
when {
branch 'master'
}
steps {
input(message: '@admin 是否要部署到生产环境', submitter: 'admin')
}
}
}
environment {
DOCKER_CREDENTIAL_ID = 'dockerhub-id'
GITHUB_CREDENTIAL_ID = 'github-id'
KUBECONFIG_CREDENTIAL_ID = 'demo-kubeconfig'
REGISTRY = 'docker.io'
DOCKERHUB_NAMESPACE = '755907724'
GITHUB_ACCOUNT = 'kubesphere'
APP_NAME = 'ruoyi'
BRANCH_NAME = 'master'
}
parameters {
string(name: 'TAG_NAME', defaultValue: '', description: '')
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/fulinzhongguo/RuoYi-Cloud.git
git@gitee.com:fulinzhongguo/RuoYi-Cloud.git
fulinzhongguo
RuoYi-Cloud
RuoYi-Cloud
master

搜索帮助