octo-technology / sonar-objective-c

Sonar Plugin for Objective C
517 stars 206 forks source link

run-sonar.sh always returns zero exit code by default #95

Open Gimungagap opened 9 years ago

Gimungagap commented 9 years ago

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.

cyrilpicat commented 9 years ago

no I see no point, I think it's an error