#!/bin/bash # # Perforce Search Trigger Script # # This script is meant to be called from a Perforce trigger. # It should be placed on the Perforce Server machine. # See usage information below for more details. # # NOTE: You must set your SEARCH host (including http://) and token below SEARCH_HOST="http://localhost:8088" SEARCH_TOKEN="MY-UUID-STYLE-TOKEN" SEARCH_MAXTIME=10 # DO NOT EDIT PAST THIS LINE --------------------------------------- # ME=${0##*/} function usage { cat << ! >&2 Usage: $ME -t <type> -v <value> -t: specify the event type (e.g. job, shelve, commit) -v: specify the ID value This script is meant to be called from a Perforce trigger. It should be placed on the Perforce Server machine and the following entries should be added using 'p4 triggers': SEARCH.change form-commit change "%quote%`pwd -P`/$ME%quote% -t change -v %formname%" SEARCH.commit change-commit //... "%quote%`pwd -P`/$ME%quote% -t commit -v %change%" Be sure to modify the SEARCH_HOST and SEARCH_TOKEN variable in this script as appropriate. ! exit 99 } # Trap call to self to post to SEARCH BACKGROUND_FLAG="background-call-to-curl" if [ "$1" == "$BACKGROUND_FLAG" ] then TYPE="$2" VALUE="$3" SEARCH_QUEUE="$SEARCH_HOST/api/queue/$SEARCH_TOKEN" curl \ --header "Content-Type: text/plain" \ --silent \ --output /dev/null \ --max-time ${SEARCH_MAXTIME} \ --data ${TYPE},${VALUE} \ ${SEARCH_QUEUE} RC=$? [ $RC -ne 0 ] && logger -p3 -t $ME "error ($RC) trying to post [$TYPE,$VALUE] to [$SEARCH_QUEUE]" [ $RC -eq 0 ] && logger -p3 -t $ME "no error ($RC) trying to post [$TYPE,$VALUE] to [$SEARCH_QUEUE]" exit 0 fi # Parse arguments while getopts :t:v:h OPT do case "$OPT" in t) TYPE="$OPTARG" ;; v) VALUE="$OPTARG" ;; h) usage ;; *) logger -p3 -t $ME -s "unknown argument [-$OPTARG]" && usage ;; esac done # Sanity check supplied arguments [ -z "$TYPE" ] && logger -p3 -t $ME -s "no event type supplied" && usage [ -z "$VALUE" ] && logger -p3 -t $ME -s "no value supplied" && usage [ -z "$SEARCH_HOST" ] || [ "$SEARCH_HOST" == "http://my-SEARCH-host" ] && logger -p3 -t $ME -s "SEARCH_HOST empty or default; please update in this script" && exit 1 [ -z "$SEARCH_TOKEN" ] || [ "$SEARCH_TOKEN" == "MY-UUID-STYLE-TOKEN" ] && logger -p3 -t $ME -s "SEARCH_TOKEN empty or default; please update in this script" && exit 1 # Post the event to SEARCH # (call self, but detach to the background) $0 "$BACKGROUND_FLAG" "$TYPE" "$VALUE" > /dev/null 2>&1 < /dev/null & # Always return success to avoid affecting Perforce users exit 0
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 8538 | phopkins | Populate //guest/phopkins/p4-search/.... | ||
//guest/doug_scheirer/p4-search/search/build/scripts/search-queue.sh | |||||
#2 | 8501 | Doug Scheirer |
* updating to gradlew for build * make (more) Mac compatible build process * default port for default install is now 8088 * updated API doc to include the queryRaw param on POSTs * minor bug fixes for when the p4d connection drops while indexing |
||
#1 | 8476 | Doug Scheirer | p4-search copy from //depot/main/p4-search |