def deploy() { node('ubuntu') { try { stage('Deploy (Ubuntu)') { checkout scm nodejs(nodeJSInstallationName: 'Node23') { sh 'yarn install --frozen-lockfile --production=false' sh 'NODE_ENV=production yarn build' // Deploy to Cloudflare Pages using wrangler // CLOUDFLARE_API_TOKEN should be set as a Jenkins credential/env variable sh 'npx wrangler pages deploy build' } } } finally { cleanWs() } } } def buildOnLabel(label, buildCommand) { return { node(label) { stage("Checkout (${label})") { checkout scm } stage("Setup Node.js (${label})") { nodejs(nodeJSInstallationName: 'Node23') { if (isUnix()) { sh 'node -v' sh 'yarn -v' } else { bat 'node -v' bat 'yarn -v' } } } stage("Install Dependencies (${label})") { nodejs(nodeJSInstallationName: 'Node23') { if (isUnix()) { sh 'yarn install --frozen-lockfile --production=false' } else { bat 'yarn install --frozen-lockfile --production=false' } } } stage("Build (${label})") { nodejs(nodeJSInstallationName: 'Node23') { if (isUnix()) { sh "NODE_ENV=production ${buildCommand}" } else { bat "set NODE_ENV=production && ${buildCommand}" } } } stage("Archive Artifacts (${label})") { archiveArtifacts artifacts: 'app_dist/**/*.dmg, app_dist/**/*.exe', fingerprint: true } } } } try { parallel( 'Windows Build': buildOnLabel('windows', 'yarn build:electron'), 'MacOS Build': buildOnLabel('macos', 'yarn build:electron'), 'Ubuntu Deploy': { deploy() } ) echo 'All parallel stages completed successfully!' } catch (Exception e) { echo "Pipeline failed: ${e.message}" throw e }