Sha256: cd5a5d96f4f9ceee586f946969077ce5551c36f371e92e50d995f83801931030

Contents?: true

Size: 1.54 KB

Versions: 4

Compression:

Stored size: 1.54 KB

Contents

pipeline {
  agent any
  stages {
    stage("test") {
      agent { label "unittest" }
      environment {
        PARALLEL_TEST_PROCESSORS = "1"
        BUNDLE_DISABLE_EXEC_LOAD = "1"
        DOCKER_HOST = "tcp://127.0.0.1:2375"
      }
      steps {
        sh '''#!/bin/bash -l
              set -xe
              export -p
              gem env
              bundle check || bundle install --jobs=4 --path=vendor/bundle
              bundle exec mcrain pull all
              bundle exec rake parallel:spec
          '''
      }
    }
  }
  post {
    changed {
      slackNotify(currentBuild.currentResult)
    }
    aborted {
      slackNotify("ABORTED")
    }
  }
}


def slackNotify(result){
  // https://github.com/jenkinsci/slack-plugin/issues/327
  def durationString = currentBuild.durationString.replace(' and counting', '')
  def notificationMessage = {resultString ->
    "${env.JOB_NAME} - ${currentBuild.displayName} ${resultString} after ${durationString} (<${env.RUN_DISPLAY_URL}|Open>)"
  }
  switch(result){
    case "SUCCESS":
      slackSend color: 'good', message: notificationMessage("Back to normal")
      break
    case "FAILURE":
      slackSend color: 'danger', message: notificationMessage("Failure")
      break
    case "UNSTABLE":
      slackSend color: 'danger', message: notificationMessage("Unstable")
      break
    case "ABORTED":
      slackSend color: 'warning', message: notificationMessage("Aborted")
      break
    default:
      slackSend color: 'warning', message: notificationMessage("Unknown")
  }
}

/* vim:set ft=groovy: */

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mcrain-0.8.4 Jenkinsfile
mcrain-0.8.3 Jenkinsfile
mcrain-0.8.2 Jenkinsfile
mcrain-0.8.1 Jenkinsfile