farmcontrol-ui/Jenkinsfile
Tom Butcher 56ff1962dd
Some checks are pending
farmcontrol/farmcontrol-ui/pipeline/head Build started...
Split ubuntu deploy out into steps.
2026-02-01 22:25:36 +00:00

100 lines
3.0 KiB
Groovy

def deploy() {
node('ubuntu') {
try {
stage('Checkout (Ubuntu)') {
checkout scm
}
stage('Setup Node.js (Ubuntu)') {
nodejs(nodeJSInstallationName: 'Node23') {
sh 'node -v'
sh 'pnpm -v'
}
}
stage('Install Dependencies (Ubuntu)') {
nodejs(nodeJSInstallationName: 'Node23') {
sh 'pnpm install --frozen-lockfile --production=false'
}
}
stage('Build (Ubuntu)') {
nodejs(nodeJSInstallationName: 'Node23') {
sh 'NODE_ENV=production pnpm build'
}
}
stage('Deploy (Ubuntu)') {
nodejs(nodeJSInstallationName: 'Node23') {
// Deploy to Cloudflare Pages using wrangler
withCredentials([string(credentialsId: 'cloudflare-api-token', variable: 'CLOUDFLARE_API_TOKEN')]) {
sh 'pnpm 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 'pnpm -v'
} else {
bat 'node -v'
bat 'pnpm -v'
}
}
}
stage("Install Dependencies (${label})") {
nodejs(nodeJSInstallationName: 'Node23') {
if (isUnix()) {
sh 'pnpm install --frozen-lockfile --production=false'
} else {
bat 'pnpm 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', 'pnpm build:electron'),
'MacOS Build': buildOnLabel('macos', 'pnpm build:electron'),
'Ubuntu Deploy': { deploy() }
)
echo 'All parallel stages completed successfully!'
} catch (Exception e) {
echo "Pipeline failed: ${e.message}"
throw e
}