Enhance Bun integration in Jenkinsfile
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 helper functions to manage Bun installation paths for both Unix and Windows environments. - Wrapped Bun installation and dependency setup stages in a new `withBun` closure for improved readability and organization. - Ensured consistent handling of Bun installation across different stages of the CI pipeline.
This commit is contained in:
parent
0b1530a405
commit
de895fed7d
24
Jenkinsfile
vendored
24
Jenkinsfile
vendored
@ -2,6 +2,20 @@ properties([
|
|||||||
buildDiscarder(logRotator(numToKeepStr: '20'))
|
buildDiscarder(logRotator(numToKeepStr: '20'))
|
||||||
])
|
])
|
||||||
|
|
||||||
|
def bunBinDir() {
|
||||||
|
if (isUnix()) {
|
||||||
|
return "${env.HOME}/.bun/bin"
|
||||||
|
}
|
||||||
|
return "${env.USERPROFILE}/.bun/bin"
|
||||||
|
}
|
||||||
|
|
||||||
|
def withBun(Closure body) {
|
||||||
|
def sep = isUnix() ? ':' : ';'
|
||||||
|
withEnv(["PATH=${bunBinDir()}${sep}${env.PATH}"]) {
|
||||||
|
body()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
def ensureBunInstalled() {
|
def ensureBunInstalled() {
|
||||||
if (isUnix()) {
|
if (isUnix()) {
|
||||||
sh '''
|
sh '''
|
||||||
@ -13,14 +27,12 @@ def ensureBunInstalled() {
|
|||||||
fi
|
fi
|
||||||
bun -v
|
bun -v
|
||||||
'''
|
'''
|
||||||
env.PATH = "${env.HOME}/.bun/bin:${env.PATH}"
|
|
||||||
} else {
|
} else {
|
||||||
bat '''
|
bat '''
|
||||||
where bun >nul 2>nul || powershell -c "irm bun.sh/install.ps1 | iex"
|
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%
|
set PATH=%USERPROFILE%/.bun/bin;%PATH%
|
||||||
bun -v
|
bun -v
|
||||||
'''
|
'''
|
||||||
env.PATH = "${env.USERPROFILE}/.bun/bin;${env.PATH}"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,6 +55,7 @@ def buildLinux() {
|
|||||||
checkout scm
|
checkout scm
|
||||||
}
|
}
|
||||||
|
|
||||||
|
withBun {
|
||||||
stage('Setup Bun (Ubuntu)') {
|
stage('Setup Bun (Ubuntu)') {
|
||||||
ensureBunInstalled()
|
ensureBunInstalled()
|
||||||
}
|
}
|
||||||
@ -58,6 +71,7 @@ def buildLinux() {
|
|||||||
stage('Build (Ubuntu)') {
|
stage('Build (Ubuntu)') {
|
||||||
sh "VITE_BUILD_NUMBER=${env.BUILD_NUMBER} NODE_ENV=production bun run build:linux"
|
sh "VITE_BUILD_NUMBER=${env.BUILD_NUMBER} NODE_ENV=production bun run build:linux"
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
stage('Archive Artifacts (Ubuntu)') {
|
stage('Archive Artifacts (Ubuntu)') {
|
||||||
archiveArtifacts artifacts: 'app_dist/**/*.deb, app_dist/**/*.rpm', fingerprint: true
|
archiveArtifacts artifacts: 'app_dist/**/*.deb, app_dist/**/*.rpm', fingerprint: true
|
||||||
@ -75,6 +89,7 @@ def buildOnLabel(label, buildCommand) {
|
|||||||
checkout scm
|
checkout scm
|
||||||
}
|
}
|
||||||
|
|
||||||
|
withBun {
|
||||||
stage("Setup Bun (${label})") {
|
stage("Setup Bun (${label})") {
|
||||||
ensureBunInstalled()
|
ensureBunInstalled()
|
||||||
}
|
}
|
||||||
@ -98,6 +113,7 @@ def buildOnLabel(label, buildCommand) {
|
|||||||
bat "set VITE_BUILD_NUMBER=${env.BUILD_NUMBER} && set NODE_ENV=production && ${buildCommand}"
|
bat "set VITE_BUILD_NUMBER=${env.BUILD_NUMBER} && set NODE_ENV=production && ${buildCommand}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
stage("Archive Artifacts (${label})") {
|
stage("Archive Artifacts (${label})") {
|
||||||
archiveArtifacts artifacts: 'app_dist/**/farmcontrol-server-*', fingerprint: true
|
archiveArtifacts artifacts: 'app_dist/**/farmcontrol-server-*', fingerprint: true
|
||||||
@ -110,6 +126,7 @@ def setBuildNameFromPackageVersion() {
|
|||||||
node('ubuntu') {
|
node('ubuntu') {
|
||||||
stage('Set Build Name') {
|
stage('Set Build Name') {
|
||||||
checkout scm
|
checkout scm
|
||||||
|
withBun {
|
||||||
ensureBunInstalled()
|
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)\"",
|
||||||
@ -120,6 +137,7 @@ def setBuildNameFromPackageVersion() {
|
|||||||
echo "Build name set to: ${buildName}"
|
echo "Build name set to: ${buildName}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user