success
This commit is contained in:
Vendored
+29
-24
@@ -1,39 +1,44 @@
|
||||
pipeline {
|
||||
agent any
|
||||
|
||||
stages {
|
||||
stage('清理工作空间') {
|
||||
steps {
|
||||
deleteDir()
|
||||
}
|
||||
}
|
||||
stage('拉取代码') {
|
||||
steps {
|
||||
git url:'http://118.25.129.153:3000/zhihui/rongshuo.git',branch:'main'
|
||||
}
|
||||
}
|
||||
stage('使用MAVNE构建') {
|
||||
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('复制Jar包') {
|
||||
stage('复制+修复权限') {
|
||||
steps {
|
||||
sh 'cp target/rongshuo.jar /app/rongshuo.jar' // ✅ 添加 sh
|
||||
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
|
||||
'''
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// stage('Docker Compose 发布 root') {
|
||||
// steps {
|
||||
// sh '''
|
||||
// cd /mydata/docker/rongshuo
|
||||
// docker compose down
|
||||
// docker compose up -d
|
||||
// '''
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user