diff --git a/Jenkinsfile b/Jenkinsfile index 4914f8f1c..5d2ae55a5 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -32,19 +32,6 @@ pre: { // https://loopback.io/doc/en/lb3/Setting-debug-strings.html#debug-strings-reference //env.DEBUG = 'strong-remoting:shared-method' } -node { - stage('Setup') { - def packageJson = readJSON file: 'package.json' - env.VERSION = packageJson.version - - env.GIT_COMMIT_MSG = sh( - script: 'git log -1 --pretty=%B ${GIT_COMMIT}', - returnStdout: true - ).trim() - - setEnv() - } -} pipeline { agent any options { @@ -115,6 +102,10 @@ pipeline { CREDENTIALS = credentials('docker-registry') } steps { + script { + def packageJson = readJSON file: 'package.json' + env.VERSION = packageJson.version + } sh 'gulp build' dockerBuild() } @@ -145,6 +136,10 @@ pipeline { DOCKER_HOST = "${env.SWARM_HOST}" } steps { + script { + def packageJson = readJSON file: 'package.json' + env.VERSION = packageJson.version + } sh "docker stack deploy --with-registry-auth --compose-file docker-compose.yml ${env.STACK_NAME}" } } @@ -167,6 +162,11 @@ pipeline { success { script { if (env.BRANCH_NAME == 'master' && FROM_GIT) { + env.GIT_COMMIT_MSG = sh( + script: 'git log -1 --pretty=%B ${GIT_COMMIT}', + returnStdout: true + ).trim() + String message = env.GIT_COMMIT_MSG int index = message.indexOf('\n') if (index != -1) @@ -183,6 +183,7 @@ pipeline { } } unsuccessful { + setEnv() sendEmail() } }