Skip to content

Instantly share code, notes, and snippets.

@boxrick
Created May 2, 2018 11:25
Show Gist options
  • Save boxrick/9015757c0540197e1aed261a003c8231 to your computer and use it in GitHub Desktop.
Save boxrick/9015757c0540197e1aed261a003c8231 to your computer and use it in GitHub Desktop.
Shared Library Example
@Library("vagrant_ansible") _
vagrant_ansible {
provider = 'docker'
distros = [ 'xenial', 'bionic' ]
}
def call(body) {
// Load in passed in values
def config = [:]
body.resolveStrategy = Closure.DELEGATE_FIRST
body.delegate = config
body()
// Run Pipeline
pipeline {
agent none
options {
ansiColor('xterm')
disableConcurrentBuilds()
buildDiscarder(logRotator(numToKeepStr:'10'))
timeout(time: 60, unit: 'MINUTES')
}
triggers {
pollSCM('H/5 * * * *')
}
stages {
stage('Check Role') {
agent any
steps {
dir('tests') {
script {
for(int i = 0; i < config.distros.size(); i++) {
distro = config.distros[i]
sh "vagrant destroy --force || true"
sh "vagrant up --provider ${config.provider} ${distro}"
}
}
}
}
post {
always {
dir('tests') {
sh "vagrant destroy --force || true"
}
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment