message: sending messages to slack
diff: node {
  + try {
  def docker_compose = "docker run -t --rm -e BUILD_TAG=\$BUILD_TAG -v \$WORKSPACE:\$WORKSPACE -v /var/run/docker.sock:/var/run/docker.sock -w \$WORKSPACE docker/compose:1.13.0 -f docker-compose.ci.yaml -p lagoon"
  env.SAFEBRANCH_NAME = env.BRANCH_NAME.toLowerCase().replaceAll('%2f','-')
  deleteDir()
  + notifySlack('RECEIVED')
  +
  stage ('Checkout') {
  checkout scm
  }
  lock('minishift') {
  + notifySlack()
  ansiColor('xterm') {
  try {
  parallel (
  @@ -70,7 +74,12 @@ node {
  }
  }
  }
  -
  + } catch (e) {
  + currentBuild.result = 'FAILURE'
  + throw e
  + } finally {
  + notifySlack(currentBuild.result)
  + }
  }
  @@ -82,3 +91,26 @@ def cleanup(docker_compose) {
  echo "cleanup failed, ignoring this."
  }
  }
  +
  +def notifySlack(String buildStatus = 'STARTED') {
  + // Build status of null means success.
  + buildStatus = buildStatus ?: 'SUCCESS'
  +
  + def color
  +
  + if (buildStatus == 'STARTED') {
  + color = '#68A1D1'
  + } else if (buildStatus == 'SUCCESS') {
  + color = '#BDFFC3'
  + } else if (buildStatus == 'UNSTABLE') {
  + color = '#FFFE89'
  + } else if (buildStatus == 'RECEIVED') {
  + color = '#D4DADF'
  + } else {
  + color = '#FF9FA1'
  + }
  +
  + def msg = "${buildStatus}: `${env.JOB_NAME}` #${env.BUILD_NUMBER}:\n${env.BUILD_URL}"
  +
  + slackSend(color: color, message: msg)
  +}
  