Refactor Bun installation checks in Jenkinsfile
Some checks failed
farmcontrol/farmcontrol-server/pipeline/head There was a failure building this commit

- Renamed the function from `ensureBunInstalled` to `checkBun` for clarity.
- Simplified the Bun version check process by removing installation commands, focusing solely on verifying Bun's presence.
- Updated stage names in the CI pipeline to reflect the new function and improve readability.
This commit is contained in:
Tom Butcher 2026-07-28 22:16:32 +01:00
parent de895fed7d
commit b2db8f0aa0

28
Jenkinsfile vendored
View File

@ -16,23 +16,11 @@ def withBun(Closure body) {
}
}
def ensureBunInstalled() {
def checkBun() {
if (isUnix()) {
sh '''
set -eu
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
'''
sh 'bun -v'
} else {
bat '''
where bun >nul 2>nul || %SystemRoot%/System32/WindowsPowerShell/v1.0/powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "irm bun.sh/install.ps1 | iex"
set PATH=%USERPROFILE%/.bun/bin;%PATH%
bun -v
'''
bat 'bun -v'
}
}
@ -56,8 +44,8 @@ def buildLinux() {
}
withBun {
stage('Setup Bun (Ubuntu)') {
ensureBunInstalled()
stage('Check Bun (Ubuntu)') {
checkBun()
}
stage('Install Dependencies (Ubuntu)') {
@ -90,8 +78,8 @@ def buildOnLabel(label, buildCommand) {
}
withBun {
stage("Setup Bun (${label})") {
ensureBunInstalled()
stage("Check Bun (${label})") {
checkBun()
}
stage("Install Dependencies (${label})") {
@ -127,7 +115,7 @@ def setBuildNameFromPackageVersion() {
stage('Set Build Name') {
checkout scm
withBun {
ensureBunInstalled()
checkBun()
def version = sh(
script: "bun --eval \"console.log(JSON.parse(await Bun.file('package.json').text()).version)\"",
returnStdout: true