mc1arke / sonarqube-community-branch-plugin

A plugin that allows branch analysis and pull request decoration in the Community version of Sonarqube
GNU Lesser General Public License v3.0
2.22k stars 521 forks source link

BitBucket PR decoration exception #334

Closed Drimix20 closed 3 years ago

Drimix20 commented 3 years ago

Describe the bug During BitBucket decoration by reported issue plugin fails with exception

2021.04.11 19:15:01 ERROR ce[AXjCW8cZ1xEgc-GeocKM][o.s.c.t.p.a.p.PostProjectAnalysisTasksExecutor] Execution of task class com.github.mc1arke.sonarqube.plugin.ce.pullrequest.PullRequestPostAnalysisTask failed
com.github.mc1arke.sonarqube.plugin.ce.pullrequest.bitbucket.client.BitbucketException: Bitbucket responded with an error status (404)
        at com.github.mc1arke.sonarqube.plugin.ce.pullrequest.bitbucket.client.BitbucketServerClient.validate(BitbucketServerClient.java:207)
        at com.github.mc1arke.sonarqube.plugin.ce.pullrequest.bitbucket.client.BitbucketServerClient.getServerProperties(BitbucketServerClient.java:178)
        at com.github.mc1arke.sonarqube.plugin.ce.pullrequest.bitbucket.client.BitbucketServerClient.supportsCodeInsights(BitbucketServerClient.java:142)
        at com.github.mc1arke.sonarqube.plugin.ce.pullrequest.bitbucket.BitbucketPullRequestDecorator.decorateQualityGateStatus(BitbucketPullRequestDecorator.java:74)
        at com.github.mc1arke.sonarqube.plugin.ce.pullrequest.PullRequestPostAnalysisTask.finished(PullRequestPostAnalysisTask.java:160)
        at org.sonar.ce.task.projectanalysis.api.posttask.PostProjectAnalysisTasksExecutor.executeTask(PostProjectAnalysisTasksExecutor.java:118)
        at org.sonar.ce.task.projectanalysis.api.posttask.PostProjectAnalysisTasksExecutor.finished(PostProjectAnalysisTasksExecutor.java:109)
        at org.sonar.ce.task.step.ComputationStepExecutor.executeListener(ComputationStepExecutor.java:91)
        at org.sonar.ce.task.step.ComputationStepExecutor.execute(ComputationStepExecutor.java:63)
        at org.sonar.ce.task.projectanalysis.taskprocessor.ReportTaskProcessor.process(ReportTaskProcessor.java:81)
        at org.sonar.ce.taskprocessor.CeWorkerImpl$ExecuteTask.executeTask(CeWorkerImpl.java:235)
        at org.sonar.ce.taskprocessor.CeWorkerImpl$ExecuteTask.run(CeWorkerImpl.java:217)
        at org.sonar.ce.taskprocessor.CeWorkerImpl.findAndProcessTask(CeWorkerImpl.java:162)
        at org.sonar.ce.taskprocessor.CeWorkerImpl$TrackRunningState.get(CeWorkerImpl.java:137)
        at org.sonar.ce.taskprocessor.CeWorkerImpl.call(CeWorkerImpl.java:89)
        at org.sonar.ce.taskprocessor.CeWorkerImpl.call(CeWorkerImpl.java:53)
        at com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly(TrustedListenableFutureTask.java:125)
        at com.google.common.util.concurrent.InterruptibleTask.run(InterruptibleTask.java:69)
        at com.google.common.util.concurrent.TrustedListenableFutureTask.run(TrustedListenableFutureTask.java:78)
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
        at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
        at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.base/java.lang.Thread.run(Unknown Source)

To Reproduce Steps to reproduce the behavior:

  1. Configured integration ALM integration with BitBucket Server (Decoration and ALM hihlighted as ok/green)
  2. Configured correct Project Key and Slug in Project > General Settings > Pull Request Decoration
  3. Perform analysis by sonar-scanner-cli\bin\sonar-scanner.bat -Dsonar.pullrequest.key= -Dsonar.pullrequest.branch= -Dsonar.pullrequest.base= -Dsonar.projectBaseDir= -Dsonar.core.serverBaseURL=http://127.0.0.1:9000/ -X -e
  4. Analysis finished successfuly, errors are visible for Pull Request branch in Sonar Qube
  5. Log file ce.log contains exception

Expected behaviour Decorated pull request with known issues detected by SonarQube.

Software Versions

michalip commented 3 years ago

@mc1arke Facing the same issue . This issue shows it's on open, any idea if there is a resolution or a merge any time soon?

Screenshot 2021-06-29 162810

michalip commented 3 years ago

Ok my issue was not using the right personal access token. Now the request is going through and I need to look into the issue with the prebuild merge commits

mc1arke commented 3 years ago

A change to allow logging of Bitbucket API requests and responses is included in v1.9.0 of the plugin. Please upgrade to this version and file a new issue if you can replicate the issue with debug logging.

mc1arke commented 3 years ago

Backported to 1.8.1 of the plugin for Sonarqube 8.9 support.

NILM1 commented 2 years ago

I know this ticket is closed but I'm having same issue as the original bug ticket. I set sonar.log.level=DEBUG and am still receiving the same amount of debug logging as above Bitbucket responded with an error status (404). Do I need to set other analysis parameters to get further information from the ce logs?

mc1arke commented 2 years ago

It's the compute engine component that would generate the additional logs, so you'd want to set sonar.log.level.ce to DEBUG, run your attempted decoration, and then check the CE logs.

romash1408 commented 2 years ago

@Drimix20, @NILM1 I had the same issue and what I found is that there should be no slash at end of bitbucket server url setting @mc1arke I think we should add check base url before sending requests to prevent // in request url