-
Notifications
You must be signed in to change notification settings - Fork 16
/
jenkins-chef-precise
executable file
·71 lines (56 loc) · 1.8 KB
/
jenkins-chef-precise
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/bash
#
# $1 = test repo number
#
# force a local default so this can be run on command line
DISTRELEASE=${DISTRELEASE-ubuntu-precise}
PACKAGE_REPO=${PACKAGE_REPO-proposed-packages}
set -e
set -x
[ -e $(dirname $0)/jenkins-deb-common ] || exit 1
. $(dirname $0)/jenkins-deb-common
jenkins_init
jenkins_set_vars
# Cleanup
rm -rf chef-cookbooks || :
# Get defined branch of chef-cookbooks
git clone --recursive --branch ${GIT_BRANCH} https://github.com/rcbops/chef-cookbooks/
# Grab knife config etc..
echo "Copying chef configuration files"
# Setup chef to use our jenkins server
#wget -O - -q http://c308412.r12.cf1.rackcdn.com/chef-server.tgz | tar -C chef-cookbooks/ -zxvf -
cp -r ~/.chef chef-cookbooks
# Move into the downloaded cookbooks directory
cd chef-cookbooks
# RVM is throwing an unbound variable error
set +u
set +x
# Tell RVM to use Ruby-1.9.3
source /usr/local/rvm/scripts/rvm
rvm use 1.9.3
# Setup array of cookbooks to check with FoodCritic
declare -a cookbooks
cookbooks=( collectd-graphite dsh glance graphite hardware horizon keystone monit nova osops-utils swift )
for book in ${cookbooks[@]}; do
echo "Running FoodCritic against $book"
# Epic fail on any violations (http://acrmp.github.com/foodcritic)
if ! ( foodcritic -f any -f ~FC023 -f ~FC020 -f ~FC005 -f ~FC024 cookbooks/$book ); then
echo "$book cookbook violates FoodCritic ruleset"
exit 1
fi
done;
echo "Uploading Cookbooks"
# Using knife, as rake exits 0 even if knife throws an error
if ! ( knife cookbook upload --all ); then
echo "Unable to upload cookbooks"
exit 1
fi
echo "Uploading Roles"
# Using knife, as rake exits 0 even if knife throws an error
if ! ( knife role from file roles/*.rb ); then
echo "Unable to upload roles"
exit 1
fi
cd ..
# Cleanup after ourselves
rm -rf chef-cookbooks