-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathgate-upstream-repo-commits-parent
78 lines (62 loc) · 2.23 KB
/
gate-upstream-repo-commits-parent
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
72
73
74
75
76
77
78
#!/bin/bash
set -e
set -x
# Once a repo is known to have upstream changes, start of a gate job to verify
# those changes
start_gate_subjob(){
job_name="$1"
curl -X POST -s -K ~/.rcbjenkins-jenkins-creds \
-d "GIT_BRANCH=${branch}&SUBMODULE=${submodule}" \
${JENKINS_URL}/job/${job_name}/buildWithParameters
}
# skip these modules from the auto-repo-update.
SKIP_REGEX="rcbops-cookbooks"
branches='master'
for branch in $branches; do
echo "checking submodule updates for ${branch}"
echo "========================================"
rm -fr chef-cookbooks
git clone git://github.com/rcbops/chef-cookbooks
pushd chef-cookbooks
git checkout $branch
declare -a updated
# get list of submodules to check
repolist=$(awk '/path/{submodule=$3}; /url/ && $3 !~/'"${SKIP_REGEX}"'/ {print submodule}' .gitmodules)
# check each and fire off downstream job if repo has changed
for repo in ${repolist}; do
# get bare submodule name
submodule=$(echo ${repo##*/}|cut -d'.' -f1)
#update submodule
git submodule init
git submodule update cookbooks/${submodule}
# compare current, and master, and fire tests if different
pushd cookbooks/${submodule}
current_ref=$(git reflog | head -1 | cut -d' ' -f1)
git checkout master
git pull
master_ref=$(git reflog | head -1 | cut -d' ' -f1)
if [ "${current_ref}" = "${master_ref}" ] ; then
echo "upstream $submodule cookbook has not changed. Nothing to do here, move along please..."
else
echo "$submodule cookbook has some updates. Triggering gate job to test..."
if [[ "$url" =~ 'ceph-cookbooks' ]]; then
start_gate_subjob gate-upstream-repo-commits-ceph
else
start_gate_subjob gate-upstream-repo-commits
fi
updated=("${updated[@]}" "${branch}:${submodule}")
fi
popd
done
# clean up
popd
rm -fr chef-cookbooks
echo
done
if [ ! -z $updated ] ; then
echo "The following submodules had updates, and downstream tests were kicked off for them:"
echo ${updated[@]}
else
echo "There are no updates to any submodules today"
fi
exit 0