代码拉取完成,页面将自动刷新
pipeline {
agent {
label 'node-01'
}
environment {
IMAGE_PROJECT = 'ruoyi'
IMAGE_NAME = 'ruoyi-admin'
IMAGE_TAG = "v3.8.2"
REGISTRY_NAME = 'harbor.banh.com'
}
stages {
stage('checkout') {
steps {
checkout scmGit(
branches: [[name: '*/master']],
extensions: [],
userRemoteConfigs: [[
credentialsId: '6362b3c0-0cd5-4a12-9ee7-a0dd827bb54d',
url: '[email protected]:root/RuoYi-Vue.git'
]]
)
}
}
stage('Clean') {
steps {
sh """
docker rm -f ruoyi-admin ruoyi-nginx || true
docker image prune -f || true
docker rmi -f ${REGISTRY_NAME}/${IMAGE_PROJECT}/${IMAGE_NAME}:${IMAGE_TAG} || true
docker rmi -f ${REGISTRY_NAME}/${IMAGE_PROJECT}/ruoyi-nginx:${IMAGE_TAG} || true
"""
}
}
stage('Build') {
steps {
sh 'chmod +x ./mvnw && ./mvnw clean package -DskipTests'
sh "cd ruoyi-admin && docker build -t ${REGISTRY_NAME}/${IMAGE_PROJECT}/${IMAGE_NAME}:${IMAGE_TAG} ."
}
}
stage('Nvm Build') {
steps {
sh """
cd ruoyi-ui && npm install --registry=https://registry.npmmirror.com && \
npm run build:prod && \
docker build -t ${REGISTRY_NAME}/${IMAGE_PROJECT}/ruoyi-nginx:${IMAGE_TAG} .
"""
}
}
stage('Push Image') {
steps {
withCredentials([usernamePassword(
credentialsId: '4451a28c-f163-488e-8810-e0e71b9684dc',
passwordVariable: 'REGISTRY_PASSWORD',
usernameVariable: 'REGISTRY_USER')]) {
sh "echo $REGISTRY_PASSWORD | docker login --username $REGISTRY_USER --password-stdin $REGISTRY_NAME"
}
sh "docker push ${REGISTRY_NAME}/${IMAGE_PROJECT}/${IMAGE_NAME}:${IMAGE_TAG}"
sh "docker push ${REGISTRY_NAME}/${IMAGE_PROJECT}/ruoyi-nginx:${IMAGE_TAG}"
}
}
stage('deploy') {
steps {
sh """
docker run -d -p 38080:8080 -u root \
--network my-network \
-e TZ="Asia/Shanghai" \
--name ${IMAGE_NAME} ${REGISTRY_NAME}/${IMAGE_PROJECT}/${IMAGE_NAME}:${IMAGE_TAG}
docker run -d -p 38081:80 -u root \
--network my-network \
-e TZ="Asia/Shanghai" \
--name ruoyi-nginx ${REGISTRY_NAME}/${IMAGE_PROJECT}/ruoyi-nginx:${IMAGE_TAG}
"""
}
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。