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

Fix Bitbucket PR reports #586

Merged
merged 3 commits into from
Jun 18, 2022
Merged

Conversation

jochim-vd
Copy link

@jochim-vd jochim-vd commented Apr 19, 2022

With the Sonar 9.4 support the project key and repository slug for Bitbucket repositories got swapped, causing the plugin not being able to find the repository to send the PR report to.

The available ObjectMapper modules also had to be registered in order write the report timestamp to JSON.

@cybe
Copy link

cybe commented Apr 22, 2022

Looks good to me! Hit by the same issues right now.

@cybe
Copy link

cybe commented Apr 22, 2022

Excuse me for hijacking this PR, but after applying your changes the report could still not being send to Bitbucket Server. Bitbucket complains about a missing field "value". The error message is in German, unfortunately. "Wert" translates to "value".

2022.04.22 15:08:39 INFO  ce[AYBRY4NeO2PAtNivk9r5][c.g.m.s.p.c.p.PullRequestPostAnalysisTask] Using pull request decorator com.github.mc1arke.sonarqube.plugin.ce.pullrequest.bitbucket.BitbucketPullRequestDecorator
2022.04.22 15:08:40 ERROR ce[AYBRY4NeO2PAtNivk9r5][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.almclient.bitbucket.BitbucketException: Das Feld „Wert“ in den Datenelementen ist ein Pflichtfeld
        at com.github.mc1arke.sonarqube.plugin.almclient.bitbucket.BitbucketServerClient.validate(BitbucketServerClient.java:200)
        at com.github.mc1arke.sonarqube.plugin.almclient.bitbucket.BitbucketServerClient.uploadReport(BitbucketServerClient.java:135)
        at com.github.mc1arke.sonarqube.plugin.ce.pullrequest.bitbucket.BitbucketPullRequestDecorator.decorateQualityGateStatus(BitbucketPullRequestDecorator.java:95)
        at com.github.mc1arke.sonarqube.plugin.ce.pullrequest.PullRequestPostAnalysisTask.finished(PullRequestPostAnalysisTask.java:138)
        at org.sonar.ce.task.projectanalysis.api.posttask.PostProjectAnalysisTasksExecutor.executeTask(PostProjectAnalysisTasksExecutor.java:102)
        at org.sonar.ce.task.projectanalysis.api.posttask.PostProjectAnalysisTasksExecutor.finished(PostProjectAnalysisTasksExecutor.java:93)
        at org.sonar.ce.task.step.ComputationStepExecutor.executeListener(ComputationStepExecutor.java:90)
        at org.sonar.ce.task.step.ComputationStepExecutor.execute(ComputationStepExecutor.java:62)
        at org.sonar.ce.task.projectanalysis.taskprocessor.ReportTaskProcessor.process(ReportTaskProcessor.java:75)
        at org.sonar.ce.taskprocessor.CeWorkerImpl$ExecuteTask.executeTask(CeWorkerImpl.java:212)
        at org.sonar.ce.taskprocessor.CeWorkerImpl$ExecuteTask.run(CeWorkerImpl.java:194)
        at org.sonar.ce.taskprocessor.CeWorkerImpl.findAndProcessTask(CeWorkerImpl.java:160)
        at org.sonar.ce.taskprocessor.CeWorkerImpl$TrackRunningState.get(CeWorkerImpl.java:135)
        at org.sonar.ce.taskprocessor.CeWorkerImpl.call(CeWorkerImpl.java:87)
        at org.sonar.ce.taskprocessor.CeWorkerImpl.call(CeWorkerImpl.java:53)
        at com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly(TrustedListenableFutureTask.java:131)
        at com.google.common.util.concurrent.InterruptibleTask.run(InterruptibleTask.java:74)
        at com.google.common.util.concurrent.TrustedListenableFutureTask.run(TrustedListenableFutureTask.java:82)
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:829)
2022.04.22 15:08:40 INFO  ce[AYBRY4NeO2PAtNivk9r5][o.s.c.t.p.a.p.PostProjectAnalysisTasksExecutor] Pull Request Decoration | status=FAILED | time=190ms

I'll take a deep dive into this next week. But maybe somebody already experienced this as well.

This is what is being sent to Bitbucket: https://gist.github.com/cybe/f585dcc4b21b5630811ab747a7effed8
Maybe its the code coverage with the value of "null".

Copy link
Contributor

@johnou johnou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see feedback.

Repository slug and project key got mixed up for the Bitbucket server
config causing Sonar to not find the repo defined in the ui on Bitbucket
@mc1arke
Copy link
Owner

mc1arke commented Apr 26, 2022

Maybe its the code coverage with the value of "null".

Yes, the code previously forced a Zero on null value. I'll add a check for this.

Bitbucket throws an error when a report contains a percentage element
with a null value. The code coverage and duplication metrics are now
nullable in the report data passed around the plugin, bit the Bitbucket
decorator does not check or replace nulls from these fields.

This change alters the report publishing to check for nulls in either of
the coverage or duplication fields and uses Zero in their place.
@mc1arke
Copy link
Owner

mc1arke commented Apr 27, 2022

@cybe Are you able to test the snapshot from this PR to see if it fixes your issues?

@cybe
Copy link

cybe commented Apr 28, 2022

@cybe Are you able to test the snapshot from this PR to see if it fixes your issues?

@mc1arke I can confirm that it does fix my reported issue! Thank you very much 😃

@MuhKuh7
Copy link

MuhKuh7 commented May 11, 2022

Any chance this can be released soon?

GuillermoFarias
GuillermoFarias approved these changes Jun 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants