ci: simplify pipeline — docker build handles full Maven build internally

Remove separate Maven stage. The multi-stage Dockerfile already runs mvn
inside a Linux container, so Windows Jenkins just runs docker build/push.
Server-side docker login pre-configured; deploy only needs docker pull.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
这个提交包含在:
XuqmGroup 2026-04-25 06:35:49 +08:00
父节点 8d97ebf8d8
当前提交 ef9b43417e

35
Jenkinsfile vendored
查看文件

@ -1,5 +1,5 @@
pipeline { pipeline {
agent none agent any
parameters { parameters {
choice(name: 'SERVICE', choices: ['tenant-service', 'im-service', 'push-service', 'update-service'], description: '要构建的服务模块') choice(name: 'SERVICE', choices: ['tenant-service', 'im-service', 'push-service', 'update-service'], description: '要构建的服务模块')
@ -18,31 +18,11 @@ pipeline {
stages { stages {
stage('Checkout') { stage('Checkout') {
agent any steps { checkout scm }
steps {
checkout scm
stash name: 'source', includes: '**/*'
}
}
stage('Build JAR') {
agent {
docker {
image 'maven:3.9-eclipse-temurin-21'
args '-v maven-repo:/root/.m2'
}
}
steps {
unstash 'source'
sh "mvn -pl ${params.SERVICE} -am -DskipTests -q clean package"
stash name: 'jar', includes: "${params.SERVICE}/target/*.jar,${params.SERVICE}/Dockerfile,Dockerfile"
}
} }
stage('Docker Build & Push') { stage('Docker Build & Push') {
agent any
steps { steps {
unstash 'jar'
withCredentials([string(credentialsId: 'ACR_PASSWORD', variable: 'ACR_PASS')]) { withCredentials([string(credentialsId: 'ACR_PASSWORD', variable: 'ACR_PASS')]) {
script { script {
def imageName = "${ACR_REGISTRY}/${ACR_NAMESPACE}/${params.SERVICE}:${params.IMAGE_TAG}" def imageName = "${ACR_REGISTRY}/${ACR_NAMESPACE}/${params.SERVICE}:${params.IMAGE_TAG}"
@ -58,7 +38,6 @@ pipeline {
} }
stage('Deploy to Production') { stage('Deploy to Production') {
agent any
when { expression { return params.DEPLOY } } when { expression { return params.DEPLOY } }
steps { steps {
withCredentials([sshUserPrivateKey(credentialsId: 'PROD_SSH_KEY', keyFileVariable: 'SSH_KEY')]) { withCredentials([sshUserPrivateKey(credentialsId: 'PROD_SSH_KEY', keyFileVariable: 'SSH_KEY')]) {
@ -66,12 +45,10 @@ pipeline {
def svcName = params.SERVICE.replace('-service', '') def svcName = params.SERVICE.replace('-service', '')
def imageName = "${ACR_REGISTRY}/${ACR_NAMESPACE}/${params.SERVICE}:${params.IMAGE_TAG}" def imageName = "${ACR_REGISTRY}/${ACR_NAMESPACE}/${params.SERVICE}:${params.IMAGE_TAG}"
sh """ sh """
ssh -i \${SSH_KEY} -o StrictHostKeyChecking=no ${PROD_USER}@${PROD_HOST} " ssh -i \${SSH_KEY} -o StrictHostKeyChecking=no ${PROD_USER}@${PROD_HOST} \
docker pull ${imageName} && "docker pull ${imageName} && \
cd /opt/xuqm/deploy && docker compose -f ${COMPOSE_FILE} up -d --no-deps ${svcName} && \
docker compose -f ${COMPOSE_FILE} up -d --no-deps ${svcName} && docker image prune -f"
docker image prune -f
"
""" """
} }
} }