From 5fdb06c1a53ed45ade709f715a0a67d6f61faf48 Mon Sep 17 00:00:00 2001 From: XuqmGroup Date: Fri, 24 Apr 2026 21:42:58 +0800 Subject: [PATCH] ci: use Docker agent for yarn build stage on Windows Jenkins Run yarn install/build inside node:22-alpine Linux container via Docker Pipeline plugin; Docker/SSH deploy stages remain on native agent. Co-Authored-By: Claude Sonnet 4.6 --- Jenkinsfile | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index f8248d9..c69930e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,5 +1,5 @@ pipeline { - agent any + agent none parameters { choice(name: 'APP', choices: ['tenant-platform', 'ops-platform'], description: '要构建的 Web 应用') @@ -18,22 +18,36 @@ pipeline { stages { stage('Checkout') { - steps { checkout scm } + agent any + steps { + checkout scm + stash name: 'source', includes: '**/*' + } } stage('Install & Build') { + agent { + docker { + image 'node:22-alpine' + args '-v yarn-cache:/root/.yarn' + } + } steps { + unstash 'source' dir("${params.APP}") { sh ''' yarn install --frozen-lockfile yarn build ''' } + stash name: 'dist', includes: "${params.APP}/dist/**,${params.APP}/Dockerfile" } } stage('Docker Build & Push') { + agent any steps { + unstash 'dist' withCredentials([string(credentialsId: 'ACR_PASSWORD', variable: 'ACR_PASS')]) { script { def imageName = "${ACR_REGISTRY}/${ACR_NAMESPACE}/web-${params.APP}:${params.IMAGE_TAG}" @@ -49,6 +63,7 @@ pipeline { } stage('Deploy to Production') { + agent any when { expression { return params.DEPLOY } } steps { withCredentials([sshUserPrivateKey(credentialsId: 'PROD_SSH_KEY', keyFileVariable: 'SSH_KEY')]) {