sibskull

Script for show current tasks and task status for git.alt

Apr 25th, 2014
155
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/sh
  2.  
  3. # Script for show current tasks and task status for ALT Linux build system
  4. # (c) Andrey Cherepanov <cas@altlinux.org>
  5.  
  6. # Usage: gtl [<task num>]
  7.  
  8. # Note: you should have access to git.alt to show you own tasks
  9.  
  10. task="$1"
  11.  
  12. grept()
  13. {
  14.   pattern=$1
  15.   shift
  16.   esc=$(printf "\033")
  17.   sed 's"'"$pattern"'"'$esc'[33m&'$esc'[0m"g' "$@"
  18. }
  19.  
  20. grepe()
  21. {
  22.   pattern=$1
  23.   shift
  24.   esc=$(printf "\033")
  25.   sed 's"'"$pattern"'"'$esc'[31m&'$esc'[0m"g' "$@"
  26. }
  27.  
  28. if [ -n "$task" ]; then
  29.         # Dump task log and exit
  30.         log="$(curl -s "http://git.altlinux.org/tasks/$task/" | grep '^<h2>Status' | cut -f2 -d '"')"
  31.         if [ -n "$log" ]; then
  32.                 curl -s "http://git.altlinux.org/tasks/$task/$log" | grept '^#.*$' | grepe '^\(E\|error\): .*$'
  33.         else
  34.                 echo "Unable to show log for task #$task"
  35.         fi
  36.         exit
  37. fi
  38.  
  39. # Show complete task list
  40. ssh git.alt task ls | while read l
  41. do
  42.         status="$(echo $l | cut -f2 -d ' ')"
  43.         case "$status" in
  44.                 BUILDING)
  45.                         echo -e "\033[33m$l\033[0m"
  46.                         ;;
  47.                 AWAITING)
  48.                         echo -e "\033[36m$l\033[0m"
  49.                         ;;
  50.                 TESTED)
  51.                         echo -e "\033[32m$l\033[0m"
  52.                         ;;
  53.                 FAILED)
  54.                         echo -e "\033[35m$l\033[0m"
  55.                         ;;
  56.                 *)
  57.                         echo "$l"
  58.                         ;;
  59.         esac
  60. done
RAW Paste Data