Files
2026-06-18 14:10:35 +08:00

44 lines
1.3 KiB
Groovy
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
pipeline {
agent any
stages {
stage('清理工作空间') {
steps { deleteDir() }
}
stage('拉取代码') {
steps {
git url:'http://118.25.129.153:3000/zhihui/rongshuo.git', branch:'main'
}
}
stage('MAVEN构建') {
steps {
withMaven(maven: 'Maven3') {
sh 'mvn clean package -DskipTests'
}
sh 'ls -lh target/rongshuo.jar'
}
}
stage('复制+修复权限') {
steps {
sh '''
# 复制到挂载目录(对应宿主机 /mydata/docker/rongshuo
cp target/rongshuo.jar /app/rongshuo/rongshuo.jar
# ⭐ 关键:给所有用户读权限,解决 Jenkins uid 问题
chmod 644 /app/rongshuo/rongshuo.jar
ls -lh /app/rongshuo/
'''
}
}
stage('Docker部署') {
steps {
dir('/app/rongshuo') {
sh '''
docker compose down
docker compose up -d --build
sleep 3
docker compose logs --tail=20
'''
}
}
}
}
}