From 32c7f20a836667457d451436f09696f946a37df3 Mon Sep 17 00:00:00 2001 From: Huaxu Wan Date: Fri, 2 Dec 2011 12:53:04 +0800 Subject: [PATCH] build.sh: show queue info --- data/build.sh | 41 ++++++++++++++++++++++++++++------------- data/packaging.sh | 2 +- 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/data/build.sh b/data/build.sh index 0e1025f..57d1b8f 100644 --- a/data/build.sh +++ b/data/build.sh @@ -59,21 +59,36 @@ echo "Submiting your changes to build server" curl -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" -sleep 1 +sleep 2 + last_id=`curl -s -u$user:$passwd "$HUDSON_SERVER/job/build/lastBuild/buildNumber"` +result_json=`curl -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. +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 -s -u$user:$passwd "$HUDSON_SERVER/job/build/lastBuild/buildNumber") + if [ "$last_id" != "$ret_id" ]; then + result_json=`curl -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 + last_id=$ret_id + echo '' + break + fi + last_id=$ret_id + else + echo -n . + sleep 1 + fi + done +fi -# In case the last commit is not made by the user, supposed the last job triggered by '$user' is the one. -while : -do - result_json=`curl -s -u$user:$passwd "$HUDSON_SERVER/job/build/$last_id/api/json"` - username=`echo $result_json|python -mjson.tool |grep "userName" |cut -d'"' -f4` - if [ x$username != x$user ]; then - last_id=`expr $last_id - 1` - else - build_id=$last_id - break - fi -done +build_id=$last_id offset=0 while : diff --git a/data/packaging.sh b/data/packaging.sh index 1e1a3ff..61b86c8 100644 --- a/data/packaging.sh +++ b/data/packaging.sh @@ -204,7 +204,7 @@ get_srctar_md5sum() project=$2 info_msg "Geting md5sum about package $project, at $tag" string=`curl -s -i -u$user:$passwd -Fjson='{"parameter": [{"name": "tag", "value": "'$tag'"},{"name":"project", "value":"'$project'"}]}' -FSubmit=Build "$HUDSON_SERVER/job/srctar_md5sum/build"` - sleep 0.5 + sleep 2 last_id=`curl -s -u$user:$passwd "$HUDSON_SERVER/job/srctar_md5sum/lastBuild/buildNumber"` result_json=`curl -s -u$user:$passwd "$HUDSON_SERVER/job/srctar_md5sum/$last_id/api/json"` -- 2.7.4