Skip to content

Instantly share code, notes, and snippets.

@leitu
Last active January 19, 2018 05:25
Show Gist options
  • Save leitu/1ce6872e287a94a66233450db51a4499 to your computer and use it in GitHub Desktop.
Save leitu/1ce6872e287a94a66233450db51a4499 to your computer and use it in GitHub Desktop.
pipeline {
agent any
parameters {
string(name: 'COOKBOOKS', defaultVaule: "[jenkins,common,base]", description:"Add your cookbooks as []")
}
stages {
stage('fetch target chef') {
steps {
git 'ssh://git@github.com/leitu/chef-cookbook.git'
}
}
stage('Testing - Staging') {
steps {
dir('cookbooks') {
script {
def cookbooks = ${params.COOKBOOKS}.trim().replaceAll(~/^\[|\]$/, '').split(',')
for (String item:cookbooks ) {
sh "cookstyle ${item}"
}
}
}
}
}
stage('Diff - Cookbooks') {
steps {
dir('cookbooks') {
script {
def cookbooks = "${params.COOKBOOKS}".trim().replaceAll(~/^\[|\]$/, '').split(',')
for (String item:cookbooks ) {
echo 'Diff start'
sh """
knife cookbook download ${item} -N -d old_${item}
diff -r old_${item}/* ${item} || true
"""
}
}
}
}
}
stage('Sanity check') {
steps {
input "Does the staging environment look ok?"
}
}
stage('Deploy - Production') {
steps {
sh 'echo done'
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment