Update comments.
[git-central.git] / server / post-receive-hudson
index 23ccfba..9f57efa 100644 (file)
@@ -2,8 +2,6 @@
 
 . $(dirname $0)/functions
 
-email="$USER@payflex.com"
-
 while read oldrev newrev refname ; do
        case "$refname" in
                refs/tags/*)
@@ -18,6 +16,11 @@ while read oldrev newrev refname ; do
                        ;;
        esac
 
+       ignored=" $(git config hooks.post-receive-hudson.ignored) "
+       if [[ $ignored =~ " $short_refname " ]] ; then
+               exit 0
+       fi
+
        branch_config=$(wget -O - http://cbas1:8080/hudson/job/${short_refname}/config.xml 2>/dev/null)
        if [ $? -ne 0 ] ; then
                # Create the job
@@ -27,15 +30,15 @@ while read oldrev newrev refname ; do
                        exit 0
                fi
 
+               # Replace stable with our branch
                branch_config="${stable_config/<branch>stable</<branch>$short_refname<}"
 
-               if [ "${branch_config/$email/}" == "$branch_config" ] ; then
-                       branch_config="${branch_config/<recipients>/<recipients>$email }"
+               # Add email to recipients list
+               if [ "${branch_config/$USER_EMAIL/}" == "$branch_config" ] ; then
+                       branch_config="${branch_config/<recipients>/<recipients>$USER_EMAIL }"
                fi
 
-               echo "$branch_config" > branch_config.txt
-
-               # wget "http://cbas1:8080/hudson/createItem?name=${short_refname}&mode=copyJob&from=stable" > wget.txt
+               # Make the new job
                wget --header "Content-Type: text/xml" --post-data="$branch_config" -O - "http://cbas1:8080/hudson/createItem?name=${short_refname}" >/dev/null 2>/dev/null
                if [ $? -ne 0 ] ; then
                        display_error_message "Could not create new Hudson job for ${short_refname}"
@@ -43,12 +46,13 @@ while read oldrev newrev refname ; do
                fi
        else
                # Add email to recipients list
-               if [ "${branch_config/$email/}" == "$branch_config" ] ; then
-                       branch_config="${branch_config/<recipients>/<recipients>$email }"
+               if [ "${branch_config/$USER_EMAIL/}" == "$branch_config" ] ; then
+                       branch_config="${branch_config/<recipients>/<recipients>$USER_EMAIL }"
 
+                       # Update the config
                        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
                        if [ $? -ne 0 ] ; then
-                               display_error_message "Could not add $email to Hudson job ${short_refname}"
+                               display_error_message "Could not add $USER_EMAIL to Hudson job ${short_refname}"
                                exit 0
                        fi
                fi