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 <noreply@anthropic.com>
这个提交包含在:
XuqmGroup 2026-04-24 21:42:58 +08:00
父节点 b349ae159b
当前提交 5fdb06c1a5

19
Jenkinsfile vendored
查看文件

@ -1,5 +1,5 @@
pipeline { pipeline {
agent any agent none
parameters { parameters {
choice(name: 'APP', choices: ['tenant-platform', 'ops-platform'], description: '要构建的 Web 应用') choice(name: 'APP', choices: ['tenant-platform', 'ops-platform'], description: '要构建的 Web 应用')
@ -18,22 +18,36 @@ pipeline {
stages { stages {
stage('Checkout') { stage('Checkout') {
steps { checkout scm } agent any
steps {
checkout scm
stash name: 'source', includes: '**/*'
}
} }
stage('Install & Build') { stage('Install & Build') {
agent {
docker {
image 'node:22-alpine'
args '-v yarn-cache:/root/.yarn'
}
}
steps { steps {
unstash 'source'
dir("${params.APP}") { dir("${params.APP}") {
sh ''' sh '''
yarn install --frozen-lockfile yarn install --frozen-lockfile
yarn build yarn build
''' '''
} }
stash name: 'dist', includes: "${params.APP}/dist/**,${params.APP}/Dockerfile"
} }
} }
stage('Docker Build & Push') { stage('Docker Build & Push') {
agent any
steps { steps {
unstash 'dist'
withCredentials([string(credentialsId: 'ACR_PASSWORD', variable: 'ACR_PASS')]) { withCredentials([string(credentialsId: 'ACR_PASSWORD', variable: 'ACR_PASS')]) {
script { script {
def imageName = "${ACR_REGISTRY}/${ACR_NAMESPACE}/web-${params.APP}:${params.IMAGE_TAG}" def imageName = "${ACR_REGISTRY}/${ACR_NAMESPACE}/web-${params.APP}:${params.IMAGE_TAG}"
@ -49,6 +63,7 @@ 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')]) {