Refactor build name retrieval in Jenkinsfile to use Node.js for parsing package.json version
Some checks reported errors
farmcontrol/farmcontrol-ui/pipeline/head Something is wrong with the build of this commit
Some checks reported errors
farmcontrol/farmcontrol-ui/pipeline/head Something is wrong with the build of this commit
This commit is contained in:
parent
3c5ad2a230
commit
c613bdeff7
11
Jenkinsfile
vendored
11
Jenkinsfile
vendored
@ -1,5 +1,3 @@
|
|||||||
import groovy.json.JsonSlurperClassic
|
|
||||||
|
|
||||||
def deploy() {
|
def deploy() {
|
||||||
node('ubuntu') {
|
node('ubuntu') {
|
||||||
try {
|
try {
|
||||||
@ -90,8 +88,13 @@ def setBuildNameFromPackageVersion() {
|
|||||||
node('ubuntu') {
|
node('ubuntu') {
|
||||||
stage('Set Build Name') {
|
stage('Set Build Name') {
|
||||||
checkout scm
|
checkout scm
|
||||||
def packageJson = new JsonSlurperClassic().parseText(readFile('package.json'))
|
def version
|
||||||
def version = packageJson.version
|
nodejs(nodeJSInstallationName: 'Node23') {
|
||||||
|
version = sh(
|
||||||
|
script: "node -p \"require('./package.json').version\"",
|
||||||
|
returnStdout: true
|
||||||
|
).trim()
|
||||||
|
}
|
||||||
currentBuild.displayName = "${version}"
|
currentBuild.displayName = "${version}"
|
||||||
echo "Build name set to package.json version: ${version}"
|
echo "Build name set to package.json version: ${version}"
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user