i got strange behavior of jenkins post build task script. purpose showing build error in slack following.
edit: our jenkins running on mac osx yosemite (10.10.4) , using unity3d build tool.
slack_bot_path=$workspace/tools/bot.rb slack_bot_name="cortana" slack_bot_token=`cat $workspace/../../sendchat_token` errors=`tail -5000 ~/library/logs/unity/editor${build_number}.log | grep ": error"` ruby $slack_bot_path $slack_bot_name $slack_bot_token "build fails : $errors"
and strange behavior is, aborted on errors= line when errors has no contents (empty string). jenkins console output following.
[workspace] $ /bin/sh -xe /var/folders/j3/8x825bdn2l9dm497yjs2144c0000gn/t/hudson7348609981772923445.sh + slack_bot_path=*snip* + slack_bot_name=cortana ++ cat *snip*/../../sendchat_token + slack_bot_token=*snip* ++ tail -5000 ~/library/logs/unity/editor1710.log ++ grep ': error' + errors= post build task : failure
after change grep filter errors has contents, post build script runs correctly again.
i want report general error message (eg. build fails) when no actual errors found in logs. report detail error message when available.
of course easy inserting line send general message before grep error log every time such general message sent slack, want know reason why empty errors terminate entire script.
does encounter same issue? if so, know cause of problem? thanks.
to precise jenkins terminate build when errors empty in code because when there no output grep command, shell errorlevel set 1 automatically , therefore terminates build error errors= , can debug same printing errorlevel value. echo $errorlevel
[linux] or echo %errorlevel%
[windows]. error 0 stand success , other error codes stands failure. if want post build script executed ignoring if grep output empty , set errorlevel value in post build step of jenkins build.
errorlevel=0
try above , see if helps
Comments
Post a Comment