3 . $(dirname $0)/functions
5 while read oldrev newrev refname ; do
11 short_refname=${refname##refs/heads/}
14 echo >&2 "*** Unknown type of update to $refname"
19 ignored=" $(git config hooks.post-receive-hudson.ignored) "
20 if [[ $ignored =~ " $short_refname " ]] ; then
24 branch_config=$(wget -O - $HUDSON_URL/job/${short_refname}/config.xml 2>/dev/null)
25 if [ $? -ne 0 ] ; then
27 stable_config=$(wget -O - $HUDSON_URL/job/stable/config.xml 2>/dev/null)
28 if [ $? -ne 0 ] ; then
29 display_error_message "Could not get existing Hudson config for ${short_refname}"
33 # Replace stable with our branch
34 branch_config="${stable_config/<branch>stable</<branch>$short_refname<}"
36 # Add email to recipients list
37 if [ "${branch_config/$USER_EMAIL/}" == "$branch_config" ] ; then
38 branch_config="${branch_config/<recipients>/<recipients>$USER_EMAIL }"
42 wget --header "Content-Type: text/xml" --post-data="$branch_config" -O - "$HUDSON_URL/createItem?name=${short_refname}" >/dev/null 2>/dev/null
43 if [ $? -ne 0 ] ; then
44 display_error_message "Could not create new Hudson job for ${short_refname}"
48 # Add email to recipients list
49 if [ "${branch_config/$USER_EMAIL/}" == "$branch_config" ] ; then
50 branch_config="${branch_config/<recipients>/<recipients>$USER_EMAIL }"
53 wget --header "Content-Type: text/xml" --post-data="$branch_config" -O - "$HUDSON_URL/job/${short_refname}/config.xml" >/dev/null 2>/dev/null
54 if [ $? -ne 0 ] ; then
55 display_error_message "Could not add $USER_EMAIL to Hudson job ${short_refname}"