Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BitBucket PR decoration exception #334

Closed
Drimix20 opened this issue Apr 11, 2021 · 7 comments
Closed

BitBucket PR decoration exception #334

Drimix20 opened this issue Apr 11, 2021 · 7 comments
Labels
bug Something isn't working

Comments

@Drimix20
Copy link

Drimix20 commented Apr 11, 2021

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=<PR_ID> -Dsonar.pullrequest.branch=<PR_BRANCH> -Dsonar.pullrequest.base=<SOURCE_BRANCH> -Dsonar.projectBaseDir=<SOURCE_PATH> -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

  • SonarQube Version: Version 8.8 (build 42792)
  • Plugin Version: 1.7.0
  • BitBucket Server v6.10.1

Can I somewhere find details about performed request?

@Drimix20 Drimix20 added the bug Something isn't working label Apr 11, 2021
mc1arke added a commit that referenced this issue Jun 9, 2021
When Bitbucket Pull Request decoration fails due to an error from Bitbucket, diagnosing the cause of the failure can be challenging due to the lack of logs. This change therefore adds an interceptor to the HTTP client used in Bitbucket decoration which logs HTTP request headers and body content to the Sonarqube logs at debug level.
mc1arke added a commit that referenced this issue Jun 11, 2021
When Bitbucket Pull Request decoration fails due to an error from Bitbucket, diagnosing the cause of the failure can be challenging due to the lack of logs. This change therefore adds an interceptor to the HTTP client used in Bitbucket decoration which logs HTTP request headers and body content to the Sonarqube logs at debug level.
@michalip
Copy link

michalip commented Jun 29, 2021

@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?

  • Bitbucket v7.8.0
  • SQ 8.3.1
  • plugin sonarqube-community-branch-plugin-1.5.0.jar
  • http connection to bitbucket

Screenshot 2021-06-29 162810

@michalip
Copy link

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
Copy link
Owner

mc1arke commented Aug 14, 2021

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 mc1arke closed this as completed Aug 14, 2021
mc1arke added a commit that referenced this issue Aug 22, 2021
When Bitbucket Pull Request decoration fails due to an error from Bitbucket, diagnosing the cause of the failure can be challenging due to the lack of logs. This change therefore adds an interceptor to the HTTP client used in Bitbucket decoration which logs HTTP request headers and body content to the Sonarqube logs at debug level.

(cherry picked from commit 3759054)
@mc1arke
Copy link
Owner

mc1arke commented Aug 23, 2021

Backported to 1.8.1 of the plugin for Sonarqube 8.9 support.

@NILM1
Copy link

NILM1 commented Nov 4, 2021

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?

  • SonarQube Version: Version 8.9
  • Plugin Version: 1.8.1
  • BitBucket Server v7.9.1

@mc1arke
Copy link
Owner

mc1arke commented Nov 5, 2021

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
Copy link

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants