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 - http://cbas1:8080/hudson/job/${short_refname}/config.xml 2>/dev/null)
25 if [ $? -ne 0 ] ; then
27 stable_config=$(wget -O - http://cbas1:8080/hudson/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 branch_config="${stable_config/<branch>stable</<branch>$short_refname<}"
35 if [ "${branch_config/$USER_EMAIL/}" == "$branch_config" ] ; then
36 branch_config="${branch_config/<recipients>/<recipients>$USER_EMAIL }"
39 # wget "http://cbas1:8080/hudson/createItem?name=${short_refname}&mode=copyJob&from=stable" > wget.txt
40 wget --header "Content-Type: text/xml" --post-data="$branch_config" -O - "http://cbas1:8080/hudson/createItem?name=${short_refname}" >/dev/null 2>/dev/null
41 if [ $? -ne 0 ] ; then
42 display_error_message "Could not create new Hudson job for ${short_refname}"
46 # Add email to recipients list
47 if [ "${branch_config/$USER_EMAIL/}" == "$branch_config" ] ; then
48 branch_config="${branch_config/<recipients>/<recipients>$USER_EMAIL }"
50 wget --header "Content-Type: text/xml" --post-data="$branch_config" -O - "http://cbas1:8080/hudson/job/${short_refname}/config.xml" >/dev/null 2>/dev/null
51 if [ $? -ne 0 ] ; then
52 display_error_message "Could not add $USER_EMAIL to Hudson job ${short_refname}"