3 . $(dirname $0)/functions
5 email="$USER@payflex.com"
7 while read oldrev newrev refname ; do
13 short_refname=${refname##refs/heads/}
16 echo >&2 "*** Unknown type of update to $refname"
21 branch_config=$(wget -O - http://cbas1:8080/hudson/job/${short_refname}/config.xml 2>/dev/null)
22 if [ $? -ne 0 ] ; then
24 stable_config=$(wget -O - http://cbas1:8080/hudson/job/stable/config.xml 2>/dev/null)
25 if [ $? -ne 0 ] ; then
26 display_error_message "Could not get existing Hudson config for ${short_refname}"
30 branch_config="${stable_config/<branch>stable</<branch>$short_refname<}"
32 if [ "${branch_config/$email/}" == "$branch_config" ] ; then
33 branch_config="${branch_config/<recipients>/<recipients>$email }"
36 echo "$branch_config" > branch_config.txt
38 # wget "http://cbas1:8080/hudson/createItem?name=${short_refname}&mode=copyJob&from=stable" > wget.txt
39 wget --header "Content-Type: text/xml" --post-data="$branch_config" -O - "http://cbas1:8080/hudson/createItem?name=${short_refname}" >/dev/null 2>/dev/null
40 if [ $? -ne 0 ] ; then
41 display_error_message "Could not create new Hudson job for ${short_refname}"
45 # Add email to recipients list
46 if [ "${branch_config/$email/}" == "$branch_config" ] ; then
47 branch_config="${branch_config/<recipients>/<recipients>$email }"
49 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
50 if [ $? -ne 0 ] ; then
51 display_error_message "Could not add $email to Hudson job ${short_refname}"