Add Bun installation checks to Jenkins pipeline
Some checks failed
farmcontrol/farmcontrol-server/pipeline/head There was a failure building this commit
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:
parent
fa389e3eb7
commit
ef4f440db4
31
Jenkinsfile
vendored
31
Jenkinsfile
vendored
@ -2,6 +2,28 @@ properties([
|
|||||||
buildDiscarder(logRotator(numToKeepStr: '20'))
|
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() {
|
def writeBuildMetadata() {
|
||||||
if (isUnix()) {
|
if (isUnix()) {
|
||||||
sh '''
|
sh '''
|
||||||
@ -22,7 +44,7 @@ def buildLinux() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
stage('Setup Bun (Ubuntu)') {
|
stage('Setup Bun (Ubuntu)') {
|
||||||
sh 'bun -v'
|
ensureBunInstalled()
|
||||||
}
|
}
|
||||||
|
|
||||||
stage('Install Dependencies (Ubuntu)') {
|
stage('Install Dependencies (Ubuntu)') {
|
||||||
@ -54,11 +76,7 @@ def buildOnLabel(label, buildCommand) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
stage("Setup Bun (${label})") {
|
stage("Setup Bun (${label})") {
|
||||||
if (isUnix()) {
|
ensureBunInstalled()
|
||||||
sh 'bun -v'
|
|
||||||
} else {
|
|
||||||
bat 'bun -v'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stage("Install Dependencies (${label})") {
|
stage("Install Dependencies (${label})") {
|
||||||
@ -92,6 +110,7 @@ def setBuildNameFromPackageVersion() {
|
|||||||
node('ubuntu') {
|
node('ubuntu') {
|
||||||
stage('Set Build Name') {
|
stage('Set Build Name') {
|
||||||
checkout scm
|
checkout scm
|
||||||
|
ensureBunInstalled()
|
||||||
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
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user