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()) { if (isUnix()) {
sh ''' sh 'bun -v'
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
'''
} else { } else {
bat ''' bat 'bun -v'
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
'''
} }
} }
@ -56,8 +44,8 @@ def buildLinux() {
} }
withBun { withBun {
stage('Setup Bun (Ubuntu)') { stage('Check Bun (Ubuntu)') {
ensureBunInstalled() checkBun()
} }
stage('Install Dependencies (Ubuntu)') { stage('Install Dependencies (Ubuntu)') {
@ -90,8 +78,8 @@ def buildOnLabel(label, buildCommand) {
} }
withBun { withBun {
stage("Setup Bun (${label})") { stage("Check Bun (${label})") {
ensureBunInstalled() checkBun()
} }
stage("Install Dependencies (${label})") { stage("Install Dependencies (${label})") {
@ -127,7 +115,7 @@ def setBuildNameFromPackageVersion() {
stage('Set Build Name') { stage('Set Build Name') {
checkout scm checkout scm
withBun { withBun {
ensureBunInstalled() checkBun()
def version = sh( def version = sh(
script: "bun --eval \"console.log(JSON.parse(await Bun.file('package.json').text()).version)\"", script: "bun --eval \"console.log(JSON.parse(await Bun.file('package.json').text()).version)\"",
returnStdout: true returnStdout: true