Last active
January 19, 2018 05:25
-
-
Save leitu/1ce6872e287a94a66233450db51a4499 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pipeline { | |
agent any | |
parameters { | |
string(name: 'COOKBOOKS', defaultVaule: "[jenkins,common,base]", description:"Add your cookbooks as []") | |
} | |
stages { | |
stage('fetch target chef') { | |
steps { | |
git 'ssh://[email protected]/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