Sonar not triggered when Detekt fails in Bitrise

I have created few workflows in Bitrise.

Run Detekt and create report
Run Jacoco and create report
Run Sonar and import above reports

Everything is working fine and I get beautiful Sonar output BUT when for any reason Detekt fails, nexts workflows will not get run. It is normal, because Detekt has found an issue in the code and breaks the build., so there will be no report that Sonar can import.
My problem is we miss the Sonar report if Detekt fails. In that case, for all instances that Detekt is failing, Sonar doesn’t create any report.
Is that normal or I am missing anything?
I will be able to set ignoreFailures = false to true from Detekt side but it is not a good solution as it will success all builds even with lots of code issues.

Some of the properties:

property "detekt.sonar.kotlin.config.path", "$rootDir/quality/detekt-config.yml"
property "sonar.kotlin.detekt.reportPaths", "$buildDir/reports/detekt/detekt.xml"
plugin_kotlin_version = '1.8.22'
plugin_detekt_version = '1.23.3'
plugin_sonarqube_version = ''

I suppose you could run Detekt last, so that SonarQube analysis is still uploaded.

You won’t be able to import the deteket issues as third party issues, but maybe you can live with that.

You could also save the exit code from Detekt as a variable and check that before the end of your build. :person_shrugging:

1 Like