44 lines
1.3 KiB
Groovy
44 lines
1.3 KiB
Groovy
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
|
||
'''
|
||
}
|
||
}
|
||
}
|
||
}
|
||
} |