Add Bun installation checks to Jenkins pipeline
Some checks failed
farmcontrol/farmcontrol-server/pipeline/head There was a failure building this commit

- Introduced a function to ensure Bun is installed on both Unix and Windows environments.
- Updated the Jenkinsfile to call this function during the setup stages, improving the reliability of the build process.
- Ensured the PATH is correctly set for Bun after installation.
This commit is contained in:
Tom Butcher 2026-07-28 22:07:14 +01:00
parent fa389e3eb7
commit ef4f440db4

31
Jenkinsfile vendored
View File

@ -2,6 +2,28 @@ properties([
buildDiscarder(logRotator(numToKeepStr: '20'))
])
def ensureBunInstalled() {
if (isUnix()) {
sh '''
set -euo pipefail
export BUN_INSTALL="${HOME}/.bun"
export PATH="${BUN_INSTALL}/bin:${PATH}"
if ! command -v bun >/dev/null 2>&1; then
curl -fsSL https://bun.sh/install | bash
fi
bun -v
'''
env.PATH = "${env.HOME}/.bun/bin:${env.PATH}"
} else {
bat '''
where bun >nul 2>nul || powershell -c "irm bun.sh/install.ps1 | iex"
set PATH=%USERPROFILE%\.bun\bin;%PATH%
bun -v
'''
env.PATH = "${env.USERPROFILE}\\.bun\\bin;${env.PATH}"
}
}
def writeBuildMetadata() {
if (isUnix()) {
sh '''
@ -22,7 +44,7 @@ def buildLinux() {
}
stage('Setup Bun (Ubuntu)') {
sh 'bun -v'
ensureBunInstalled()
}
stage('Install Dependencies (Ubuntu)') {
@ -54,11 +76,7 @@ def buildOnLabel(label, buildCommand) {
}
stage("Setup Bun (${label})") {
if (isUnix()) {
sh 'bun -v'
} else {
bat 'bun -v'
}
ensureBunInstalled()
}
stage("Install Dependencies (${label})") {
@ -92,6 +110,7 @@ def setBuildNameFromPackageVersion() {
node('ubuntu') {
stage('Set Build Name') {
checkout scm
ensureBunInstalled()
def version = sh(
script: "bun --eval \"console.log(JSON.parse(await Bun.file('package.json').text()).version)\"",
returnStdout: true