Last active
December 21, 2015 10:49
-
-
Save timsutton/6294515 to your computer and use it in GitHub Desktop.
Jenkins build steps to run all autopkg recipes. Assumes the job first does a git clone of https://github.com/autopkg/autopkg
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
# (set GIT to the git binary if needed) | |
$GIT clone https://github.com/autopkg/recipes autopkg-recipes | |
$GIT clone https://github.com/keeleysam/recipes keeleysam-recipes |
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
import plistlib | |
import os | |
import sys | |
import subprocess | |
from pprint import pprint | |
from shutil import rmtree | |
from tempfile import mkdtemp | |
# Define any recipes that you want to skip in this list | |
EXCEPTIONS = [] | |
# Set DEBUG_LIST to a short list of recipes to be used instead for debugging | |
DEBUG_LIST = [] | |
def runCommand(cmd, redirect_stdout=None): | |
# overriding LC_CTYPE because without locale info, use of the tar command will fail | |
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env={'LC_CTYPE': 'en_CA.UTF-8'}) | |
out, err = p.communicate() | |
if err: | |
print >> sys.stderr, "Stderr output:" | |
print >> sys.stderr, err | |
return out | |
def main(): | |
auto_path = os.path.join(os.getcwd(), 'Code/auto') | |
recipe_search_dirs = [os.path.join(os.getcwd(), 'autopkg-recipes'), os.path.join(os.getcwd(), 'keeleysam-recipes')] | |
search_dirs_opts = [] | |
for search_dir in recipe_search_dirs: | |
search_dirs_opts.extend(['-d', search_dir]) | |
cache_path = mkdtemp() | |
munki_repo_path = mkdtemp() | |
list_recipes_cmd = [auto_path, 'list-recipes'] | |
list_recipes_cmd.extend(search_dirs_opts) | |
list_recipes_output = runCommand(list_recipes_cmd) | |
recipes = list_recipes_output.splitlines() | |
print "Processing recipes:" | |
print "\n".join(recipes) | |
if DEBUG_LIST: | |
recipes = DEBUG_LIST | |
if EXCEPTIONS: | |
for exception in EXCEPTIONS: | |
if exception in recipes: | |
recipes.remove(exception) | |
report_cmd = [auto_path, 'run', '--report-plist', '-k', 'CACHE_DIR=%s' % cache_path, '-k', 'MUNKI_REPO=%s' % munki_repo_path] | |
# report_cmd = [auto_path, 'run', '-k', 'CACHE_DIR=%s' % cache_path, '-k', 'MUNKI_REPO=%s' % munki_repo_path, '-vv'] | |
report_cmd.extend(search_dirs_opts) | |
report_cmd.extend(recipes) | |
report_plist = runCommand(report_cmd) | |
for clean_path in [cache_path, munki_repo_path]: | |
rmtree(clean_path) | |
report = plistlib.readPlistFromString(report_plist) | |
pprint(report) | |
if len(report['failures']) > 0: | |
sys.exit(1) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment