From e9b943f12e5c8b405ae3264ad6989ff31a89ff24 Mon Sep 17 00:00:00 2001 From: JF Ding Date: Thu, 8 Dec 2011 17:09:27 -0800 Subject: [PATCH] add -L option to curl cover 301 pages --- data/build.sh | 18 +++++++++--------- data/packaging.sh | 18 +++++++++--------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/data/build.sh b/data/build.sh index f92409f..8bb4a65 100644 --- a/data/build.sh +++ b/data/build.sh @@ -56,7 +56,7 @@ passwd=$(gbs cfg passwd) HUDSON_SERVER=$(gbs cfg src_server) passwdx=$(gbs cfg passwdx) echo "Submiting your changes to build server" -ret_string=$(curl -k -i -s -u$user:$passwd -Fname=package.tar.bz2 -Ffile0=@package.tar.bz2 -Fjson='{"parameter": [{"name": "package.tar.bz2", "file": "file0"},{"name":"pkg", "value":"'$prj_name'"},{"name":"parameters","value":"obsproject='$target_obsproject';passwdx='$passwdx'"}]}' -FSubmit=Build "$HUDSON_SERVER/job/build/build") +ret_string=$(curl -L -k -i -s -u$user:$passwd -Fname=package.tar.bz2 -Ffile0=@package.tar.bz2 -Fjson='{"parameter": [{"name": "package.tar.bz2", "file": "file0"},{"name":"pkg", "value":"'$prj_name'"},{"name":"parameters","value":"obsproject='$target_obsproject';passwdx='$passwdx'"}]}' -FSubmit=Build "$HUDSON_SERVER/job/build/build") echo $ret_string|grep '302' > /dev/null @@ -67,8 +67,8 @@ fi sleep 2 -last_id=`curl -k -s -u$user:$passwd "$HUDSON_SERVER/job/build/lastBuild/buildNumber"` -result_json=`curl -k -s -u$user:$passwd "$HUDSON_SERVER/job/build/$last_id/api/json"` +last_id=`curl -L -k -s -u$user:$passwd "$HUDSON_SERVER/job/build/lastBuild/buildNumber"` +result_json=`curl -L -k -s -u$user:$passwd "$HUDSON_SERVER/job/build/$last_id/api/json"` last_prj=`echo $result_json|python -mjson.tool |grep "pkg" -A1|tail -1|cut -d'"' -f4` last_user=`echo $result_json|python -mjson.tool |grep "userName" |cut -d'"' -f4` # In case the last commit is not made by the user, supposed the last job triggered by '$user' is the one. @@ -76,9 +76,9 @@ if [ "$last_prj" != "$prj_name" -o "$last_user" != "$user" ]; then echo "Your request has been put in queue waiting to process" while [ true ] do - ret_id=$(curl -k -s -u$user:$passwd "$HUDSON_SERVER/job/build/lastBuild/buildNumber") + ret_id=$(curl -L -k -s -u$user:$passwd "$HUDSON_SERVER/job/build/lastBuild/buildNumber") if [ "$last_id" != "$ret_id" ]; then - result_json=`curl -k -s -u$user:$passwd "$HUDSON_SERVER/job/build/$ret_id/api/json"` + result_json=`curl -L -k -s -u$user:$passwd "$HUDSON_SERVER/job/build/$ret_id/api/json"` last_prj=`echo $result_json|python -mjson.tool |grep "pkg" -A1|tail -1|cut -d'"' -f4` last_user=`echo $result_json|python -mjson.tool |grep "userName" |cut -d'"' -f4` if [ "$last_prj" == "$prj_name" -o "$last_user" != "$user" ]; then @@ -99,15 +99,15 @@ build_id=$last_id offset=0 while : do - result_json=`curl -k -s -u$user:$passwd "$HUDSON_SERVER/job/build/$build_id/api/json"` + result_json=`curl -L -k -s -u$user:$passwd "$HUDSON_SERVER/job/build/$build_id/api/json"` status=$(echo $result_json|python -mjson.tool |grep "building.*false") if [ -n "$status" ]; then break fi if [ -n "$verbose" ]; then - length=`curl -k -s -u$user:$passwd "$HUDSON_SERVER/rest/projects/build/$build_id/console/" | cut -d ',' -f2|cut -d ':' -f2` - curl -k -s -u$user:$passwd "$HUDSON_SERVER/rest/projects/build/$build_id/console/content" -d 'length'=$length -d 'offset'=$offset -G + length=`curl -L -k -s -u$user:$passwd "$HUDSON_SERVER/rest/projects/build/$build_id/console/" | cut -d ',' -f2|cut -d ':' -f2` + curl -L -k -s -u$user:$passwd "$HUDSON_SERVER/rest/projects/build/$build_id/console/content" -d 'length'=$length -d 'offset'=$offset -G offset=$length else echo -n '.' @@ -120,7 +120,7 @@ echo "" result=`echo $result_json|python -mjson.tool |grep result|cut -d '"' -f4` if [ x$result != xSUCCESS ]; then - curl -k -u$user:$passwd "$HUDSON_SERVER/job/build/$build_id/consoleText" -G + curl -L -k -u$user:$passwd "$HUDSON_SERVER/job/build/$build_id/consoleText" -G die 'Remote Server Exception' else echo "Your local changes has been submitted to build server." diff --git a/data/packaging.sh b/data/packaging.sh index 35dbfd9..a1191ba 100644 --- a/data/packaging.sh +++ b/data/packaging.sh @@ -203,7 +203,7 @@ get_srctar_md5sum() tag=$1 project=$2 info_msg "Getting md5sum value for package $project at ref $tag, from server ..." - string=`curl -k -s -i -u$user:$passwd -Fjson='{"parameter": [{"name": "tag", "value": "'$tag'"},{"name":"project", "value":"'$project'"}]}' -FSubmit=Build "$HUDSON_SERVER/job/srctar_md5sum/build"` + string=`curl -L -k -s -i -u$user:$passwd -Fjson='{"parameter": [{"name": "tag", "value": "'$tag'"},{"name":"project", "value":"'$project'"}]}' -FSubmit=Build "$HUDSON_SERVER/job/srctar_md5sum/build"` sleep 2 echo $string|grep '302' > /dev/null @@ -212,8 +212,8 @@ get_srctar_md5sum() die "Server Error, please check your gbs configuration." fi - last_id=`curl -k -s -u$user:$passwd "$HUDSON_SERVER/job/srctar_md5sum/lastBuild/buildNumber"` - result_json=`curl -k -s -u$user:$passwd "$HUDSON_SERVER/job/srctar_md5sum/$last_id/api/json"` + last_id=`curl -L -k -s -u$user:$passwd "$HUDSON_SERVER/job/srctar_md5sum/lastBuild/buildNumber"` + result_json=`curl -L -k -s -u$user:$passwd "$HUDSON_SERVER/job/srctar_md5sum/$last_id/api/json"` last_prj=`echo $result_json|python -mjson.tool |grep "project" -A1|tail -1|cut -d'"' -f4` last_user=`echo $result_json|python -mjson.tool |grep "userName" |cut -d'"' -f4` # In case the last commit is not made by the user, supposed the last job triggered by '$user' is the one. @@ -221,9 +221,9 @@ get_srctar_md5sum() echo "Your request has been put in waiting queue of server, waiting to active ..." while [ true ] do - ret_id=$(curl -k -s -u$user:$passwd "$HUDSON_SERVER/job/srctar_md5sum/lastBuild/buildNumber") + ret_id=$(curl -L -k -s -u$user:$passwd "$HUDSON_SERVER/job/srctar_md5sum/lastBuild/buildNumber") if [ "$last_id" != "$ret_id" ]; then - result_json=`curl -k -s -u$user:$passwd "$HUDSON_SERVER/job/srctar_md5sum/$ret_id/api/json"` + result_json=`curl -L -k -s -u$user:$passwd "$HUDSON_SERVER/job/srctar_md5sum/$ret_id/api/json"` last_prj=`echo $result_json|python -mjson.tool |grep "project" -A1|tail -1|cut -d'"' -f4` last_user=`echo $result_json|python -mjson.tool |grep "userName" |cut -d'"' -f4` if [ "$last_prj" == "$project" -o "$last_user" != "$user" ]; then @@ -243,7 +243,7 @@ get_srctar_md5sum() # Waiting until the job finished while [ true ] do - result_json=`curl -k -s -u$user:$passwd "$HUDSON_SERVER/job/srctar_md5sum/$build_id/api/json"` + result_json=`curl -L -k -s -u$user:$passwd "$HUDSON_SERVER/job/srctar_md5sum/$build_id/api/json"` status=$(echo $result_json|python -mjson.tool |grep "building.*false") if [ -n "$status" ]; then break @@ -253,17 +253,17 @@ get_srctar_md5sum() done echo "" # Execuation result - result_json=`curl -k -s -u$user:$passwd "$HUDSON_SERVER/job/srctar_md5sum/$build_id/api/json"` + result_json=`curl -L -k -s -u$user:$passwd "$HUDSON_SERVER/job/srctar_md5sum/$build_id/api/json"` result=`echo $result_json|python -mjson.tool |grep result|cut -d '"' -f4` if [ x$result != xSUCCESS ]; then echo -e "${ERR_COLOR}==== LOG FROM REMOTE SERVER ============${NO_COLOR}" - curl -k -s -u$user:$passwd "$HUDSON_SERVER/job/srctar_md5sum/$build_id/consoleText" + curl -L -k -s -u$user:$passwd "$HUDSON_SERVER/job/srctar_md5sum/$build_id/consoleText" echo -e "${ERR_COLOR}========================================${NO_COLOR}" die 'Remote Server Exception' else - srctar_md5sum=$(curl -k -s -u$user:$passwd "$HUDSON_SERVER/job/srctar_md5sum/$build_id/consoleText" | sed -n 's/.*#!#\(.*\)#!#.*/\1/p') + srctar_md5sum=$(curl -L -k -s -u$user:$passwd "$HUDSON_SERVER/job/srctar_md5sum/$build_id/consoleText" | sed -n 's/.*#!#\(.*\)#!#.*/\1/p') info_msg "md5sum output:" echo " " "$srctar_md5sum" echo "" -- 2.7.4