Created
January 19, 2013 07:36
-
-
Save yono/4571245 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
#---------------------------------------------------------------------------------------- | |
# Jenkins サーバへスクリプトの実行結果を通知するためのスクリプトです。 | |
# | |
# 以下のスクリプトを元にして、パイプで標準出力の結果を受け取るように修正しました | |
# https://github.com/akiko-pusu/misc/blob/master/misc/jenkins_wrapper.sh | |
# | |
# Usage: | |
# SCRIPT | jenkins_report.sh ${PIPESTATUS[0]} <jenkins_url> <job_name> | |
# example: | |
# pgdumpall | jenkins_report.sh ${PIPESTATUS[0]} http://jenkins.example.com pgdump_daily | |
# | |
ERR_CODE=$1 | |
JENKINS_URL=$2 | |
JOB_NAME=$3 | |
RESULT="" | |
ELAPSED_MS=100 | |
echo $ERR_CODE | |
echo $JENKINS_URL | |
echo $JOB_NAME | |
while read line | |
do | |
RESULT="$line"$SCRIPT | |
done | |
OUTFILE=$(mktemp -t jenkins_send.XXXXXXXX) | |
echo "Temp file is: $OUTFILE" >> $OUTFILE | |
echo "Jenkins URL: $JONKINS_URL" >> $OUTFILE | |
echo "Jenkins job name: $JOB_NAME" >> $OUTFILE | |
echo "Script result: $RESULT" >> $OUTFILE | |
echo "" >> $OUTFILE | |
CURLTEMP=$(mktemp -t jenkins_report_curl.XXXXXXXX) | |
echo "<run><log encoding=\"hexBinary\">$(hexdump -v -e '1/1 "%02x"' $OUTFILE)</log><result>$ERR_CODE</result><duration>${ELAPSED_MS}</duration></run>" > $CURLTEMP | |
curl -X POST -d @${CURLTEMP} ${JENKINS_URL}/job/${JOB_NAME}/postBuildResult | |
echo ${JENKINS_URL}/job/${JOB_NAME}/postBuildResult | |
echo $OUTFILE | |
echo $CURLTEMP | |
echo $ERR_CODE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment