diff --git a/Jenkinsfile b/Jenkinsfile index 055cf858f..06addc940 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -64,6 +64,18 @@ pipeline { PROJECT_NAME = 'salix' } stages { + stage('Version') { + when { + expression { RUN_BUILD } + } + steps { + script { + def packageJson = readJSON file: 'package.json' + def version = "${packageJson.version}-build${env.BUILD_ID}" + writeFile(file: 'VERSION.txt', text: version) + } + } + } stage('Install') { environment { NODE_ENV = '' @@ -120,11 +132,10 @@ pipeline { when { expression { RUN_BUILD } } + environment { + VERSION = readFile 'VERSION.txt' + } steps { - script { - def packageJson = readJSON file: 'package.json' - env.VERSION = "${packageJson.version}-build${env.BUILD_ID}" - } sh 'docker-compose build back' } } @@ -158,11 +169,10 @@ pipeline { when { expression { RUN_BUILD } } + environment { + VERSION = readFile 'VERSION.txt' + } steps { - script { - def packageJson = readJSON file: 'package.json' - env.VERSION = "${packageJson.version}-build${env.BUILD_ID}" - } sh 'gulp build' sh 'docker-compose build front' } @@ -177,12 +187,9 @@ pipeline { } environment { CREDENTIALS = credentials('docker-registry') + VERSION = readFile 'VERSION.txt' } steps { - script { - def packageJson = readJSON file: 'package.json' - env.VERSION = "${packageJson.version}-build${env.BUILD_ID}" - } sh 'docker login --username $CREDENTIALS_USR --password $CREDENTIALS_PSW $REGISTRY' sh 'docker-compose push' } @@ -209,11 +216,10 @@ pipeline { when { expression { FROM_GIT } } + environment { + VERSION = readFile 'VERSION.txt' + } steps { - script { - def packageJson = readJSON file: 'package.json' - env.VERSION = "${packageJson.version}-build${env.BUILD_ID}" - } withKubeConfig([ serverUrl: "$KUBERNETES_API", credentialsId: 'kubernetes',