Issue
I am trying to set the Build name/Build description based on the outcome of a shell script. For example, I am executing the following lines in shell:
echo `date`
if [ $test == true ]then
echo "BuildSuccess"
else
echo "NoBuild"
fi
I am then running the build step "Changes build description". In this, I have added the macro:
${BUILD_LOG,maxLines=1}
After running the job I get the output as:
[SSH] executing...
Thu May 20 00:47:42 PDT 2021
BuildSuccess
[SSH] completed
[SSH] exit-status: 0
New run description is '[...truncated 478 B...]
'
Evaluated macro: '#37'
New run name is '#37'
Finished: SUCCESS
Can anyone help me understand why the macro is getting evaluated to [...truncated 478 B...]?
Is there a way I can capture the text "BuildSuccess" from the log? I am in effect trying to capture the last line of the build log.
Please note that this is a freestyle project and not a pipeline.
Solution
I solved a similar issue by:
BUILD_LOG_REGEX
- email-ext plugin
Here is a tutorial http://siddesh-bg.blogspot.com/2012/04/using-buildlogregex-in-jenkins-email.html .
By BUILD_LOG_REGEX
the above mentioned plugin is able to query and extract parts of the build log.
Answered By - Antonio Petricca