Hi there. I had an issue with failing builds on CI when quality gate is violated. I found the reason in using run-sonar.sh script which returns other value then the sonar-runner itself. I looked through the script and found the problem: if -v option is specified then script returns the result of command:
elif [ "$vflag" = "on" ]; then
...
if [[ $returnValue != 0 && $returnValue != 5 ]] ; then
stopProgress
echo "ERROR - Command '$command $@' failed with error code: $returnValue"
exit $returnValue
fi
But otherwise it returns the result of the previous operation ($?) instead:
else
...
if [[ $returnValue != 0 && $returnValue != 5 ]] ; then
stopProgress
echo "ERROR - Command '$command $@' failed with error code: $returnValue"
exit $?
So in default mode the echo return value is used instead of the sonar-runner result and it is usually a zero. Is it a mistake or a feature? Maybe I'm missing something.
Hi there. I had an issue with failing builds on CI when quality gate is violated. I found the reason in using run-sonar.sh script which returns other value then the sonar-runner itself. I looked through the script and found the problem: if -v option is specified then script returns the result of command:
But otherwise it returns the result of the previous operation ($?) instead:
So in default mode the echo return value is used instead of the sonar-runner result and it is usually a zero. Is it a mistake or a feature? Maybe I'm missing something.