gjh.sh #1

  • //
  • p4ms/
  • dev/
  • tools/
  • gjh.sh
  • View
  • Commits
  • Open Download .zip Download (1 KB)
#!/bin/bash

# Get Job Header
# Usage: gjh.sh <job>
# where <job> can be specifie as the job name, like HMS-30 or simply 30.

declare ThisScript="${0##*/}"
declare JobBaseURL="https://swarm.workshop.perforce.com/jobs"
declare Job=
declare JobURL=
declare JobHeader=
declare JobKey="HMS"
declare JobType=
declare TmpDir=

if [[ $# -lt 1 ]]; then
   echo -e "\\nUsage: $ThisScript <Job>\\n\\ne.g.\\n\\t$ThisScript ${JobKey}-570\\n\\n${JobKey}-570 can be shortened to just 570."
   exit 1
fi

TmpDir=$(mktemp -d)

cd "$TmpDir"

for Job in $*; do
   [[ "$Job" =~ ^[0-9]+$ ]] && Job="${JobKey}-$Job"
   JobURL="$JobBaseURL/$Job"
   curl -s -k -O "$JobURL"
   JobHeader=$(grep 'first-line' $Job|head -1|sed -E -e 's/^.*first-line">//g' -e 's#</span.*$##g' -e 's#<a href=".*">##g' -e 's#</a>##g' -e "s:&#039;:':g" -e "s:&quot;:\":g" -e "s:&lt;:<:g" -e "s:&gt;:>:g")
   JobType=$(grep -E -A1 'Type.*</dt>' $Job | tail -1 | sed -E -e 's/^.*first-line">//g' -e 's#<.*$##g')

   echo -e "$Job ($JobType): $JobHeader\\n$JobURL\\n"
done

cd "$OLDPWD" || exit 1
rm -rf "$TmpDir"
# Change User Description Committed
#1 31797 C. Thomas Tyler p4 merge -b HMS_to_P4MS; p4 resolve -as; p4 submit
//guest/perforce_software/hms/tools/gjh.sh
#2 29484 C. Thomas Tyler Added URL.
#1 28447 C. Thomas Tyler Added tool to get HMS job header.