From ef4f440db471d1961ceae63409b20a382d389dd5 Mon Sep 17 00:00:00 2001 From: Tom Butcher Date: Tue, 28 Jul 2026 22:07:14 +0100 Subject: [PATCH] Add Bun installation checks to Jenkins pipeline - 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. --- Jenkinsfile | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 7bed5bd..e7d58c4 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -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