mibexsoftware / sonar-bitbucket-plugin

SonarQube plug-in to create pull request comments for found issues in Bitbucket Cloud
Other
122 stars 72 forks source link

Publishing fails after adding sonar-bitbuckit-plugin #49

Closed Simon-Raes closed 7 years ago

Simon-Raes commented 7 years ago

Actual Behavior

I'm using Jenkins pipeline to automatically build our Android apps. Depending on the branch, the Sonarqube phase of this build process should either publish the analysis to our Sonarqube site (for builds on develop) or add comments on the pull request (for builds on PR branches).

The publishing was working fine using the Sonarqube gradle plugin: https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner+for+Gradle I simply used the "./gradlew sonarqube" command to publish the results.

After adding the sonar-bitbucket-plugin to our Sonarqube I can see comments on the Bitbucket pull requests, but the publishing (for develop builds) now fails with the following error message in the logs:

20:25:57.780 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Caused by: java.lang.IllegalArgumentException: requirement failed: [sonar4bitbucket] The plug-in only works in preview or issues mode. Please set "-Dsonar.analysis.mode" accordingly.

After removing the sonar-bitbucket-plugin again, publishing again works as expected.

It seems that the "./gradlew sonarqube" command now triggers the sonar-bitbucket-plugin (which we don't need on develop builds) instead of just publishing to Sonarqube with the SonarQube Scanner for Gradle.

Expected Behavior

I would like to use both Sonarqube publishing or commenting (though not at the same time) in my automated builds. Is there a way to do this? Am I using the Scanner of bitbucket-plugin incorrectly?

Plug-in version, SonarQube version, CI system, build type

sonar-bitbucket-plugin 1.2.0 Sonarqube 6.0 Jenkins 2.46.3, using pipeline builds

mrueegg commented 7 years ago

Hi,

The error message indicates that the plug-in was run during the full (persistent) analysis triggered with "./gradlew sonarqube". This plug-in is only intended to be run in preview/issues mode. If you don't configure "sonar.bitbucket.accountName", then the plug-in is considered as inactive.

I think you don't want the plug-in to be executed for your master branch, but only for your pull request branches. For these, you don't need to run a full/persistent analysis, but only our plug-in with preview/issues mode.

Could you change your CI environment accordingly?

Simon-Raes commented 7 years ago

Thanks for your response. Is clearing the "sonar.bitbucket.accountName" property the intended way to disable the plugin?

I'll check if I can make this property value dynamic based on the current branch.

mrueegg commented 7 years ago

You're very welcome. When you don't pass this mandatory parameter, the plug-in is considered disabled.

Simon-Raes commented 7 years ago

That fixed it, thanks!