From 44cf97e2fd23ba8b46441c1318572ec3846635f6 Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Wed, 5 Aug 2020 13:29:52 +0100 Subject: [PATCH] build: Fix Jenkinsfile syntax Turns out that "when" blocks are permitted but not effectual in "post" sections so instead use a script behaviour to make the message conditional on build change. Signed-off-by: Rob Bradford --- Jenkinsfile | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 5c09adf37..8c1d56994 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -128,15 +128,20 @@ pipeline{ } post { regression { - when { branch 'master' } - slackSend (color: '#ff0000', message: '"master" branch build is now failing') + script { + if (env.BRANCH_NAME == 'master') { + slackSend (color: '#ff0000', message: '"master" branch build is now failing') + } + } } fixed { - when { branch 'master' } - slackSend (color: '#00ff00', message: '"master" branch build is now fixed') + script { + if (env.BRANCH_NAME == 'master') { + slackSend (color: '#00ff00', message: '"master" branch build is now fixed') + } + } } } - } def cancelPreviousBuilds() {