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

pullrequest decoration comments should include a link to sonarqube's task detail page and vice versa #67

Closed
jizhilong opened this issue Jan 13, 2020 · 5 comments
Labels
enhancement New feature or request

Comments

@jizhilong
Copy link
Contributor

For now, the pullrequest decoration message only contains a brief summary of the analysis, but no direct link to guide the developer to the sonarqube's task page, where he/she can view the details of each metric category. As a workaround, one can find the sonar task link at gitlabci's CI/CD pipeline page, which could be more convenient if it was already included in the pullrequest decoration message. And on sonar's task page, a link to the corresponding PR/MR page would also make life easier.

tisoft added a commit to tisoft/sonarqube-community-branch-plugin that referenced this issue Jan 13, 2020
@tisoft
Copy link
Contributor

tisoft commented Jan 13, 2020

Added PR #70 for adding the link to SonarQube into the PR comments.

@kortov
Copy link

kortov commented Jan 13, 2020

Hi I'd like to ask a question. The link the issue about is the dashboard url? Because I'd like to notice that sonar dumps https://github.com/SonarSource/sonarqube/blob/f61e29bce771e56f8d45ad07a235c0399a1a9772/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ReportPublisher.java#L230 dashboardUrl to report-task.txt file. There is a similar plugin which works with this file and I opened a PR about this dashboardUrl gabrie-allaigre/sonar-gitlab-plugin#268
maybe it would be interesting for you. But I don't see that this plugin used report-task.txt before

@tisoft
Copy link
Contributor

tisoft commented Jan 13, 2020

The summary comment links to the dashboard, the issue comments link to the issue in the file.

@mc1arke
Copy link
Owner

mc1arke commented Jan 13, 2020

For the link from Sonarqube to the PR, this functionality is currently provided by Sonarqube core if we set the url property on the BranchDto, which we don't currently do. This should be do-able in PullRequestPostAnalysisTask by having the constructor take a DbClient instance, getting the PullRequestBuildStatusDecorator to generate the PR URL (I've not yet decided if it's best to do this as a return value on the decorateQualityGateStatus call, or as another method), and then using something similar to

        try (DbSession dbSession = dbClient.openSession(false)) {
            BranchDao branchDao = dbClient.branchDao();
            Optional<BranchDto> optionalBranchDto = branchDao.selectByPullRequestKey(dbSession, projectAnalysis.getProject().getUuid(), projectAnalysis.getScannerContext().getProperties().get("sonar.pullrequest.key"));
            if (optionalBranchDto.isPresent()) {
                BranchDto branchDto = optionalBranchDto.get();
                DbProjectBranches.PullRequestData.Builder pullRequestDataBuilder = DbProjectBranches.PullRequestData.newBuilder(branchDto.getPullRequestData());
                pullRequestDataBuilder.setUrl(url);
                branchDto.setPullRequestData(pullRequestDataBuilder.build());
                branchDao.upsert(dbSession, branchDto);
            }
        }

I'll try this out when I get time and get a PR raised.

tisoft added a commit to tisoft/sonarqube-community-branch-plugin that referenced this issue Jan 13, 2020
tisoft added a commit to tisoft/sonarqube-community-branch-plugin that referenced this issue Jan 13, 2020
mc1arke pushed a commit that referenced this issue Jan 13, 2020
fixes a part of #67
@mc1arke mc1arke added the enhancement New feature or request label Feb 25, 2020
mc1arke added a commit that referenced this issue May 31, 2020
Sonarqube provides the ability to link back to the original Pull Request or Merge Request from the Pull Request overview screen if the Pull Request URL is persisted alongside the branch details. To allow this, decorators are now required to return a `DecorationResult` that contains an optional URL for the Pull Request's overview/summary page. The Gitlab and Github decorators have been updated to provide the new details, however the Bitbucket decorator defaults to returning no URL since the details are not readily available, so Bitbucket Pull Requests will continue to show no link back the the Pull Request from Sonarqube.
mc1arke added a commit that referenced this issue May 31, 2020
Sonarqube provides the ability to link back to the original Pull Request or Merge Request from the Pull Request overview screen if the Pull Request URL is persisted alongside the branch details. To allow this, decorators are now required to return a `DecorationResult` that contains an optional URL for the Pull Request's overview/summary page. The Gitlab and Github decorators have been updated to provide the new details, however the Bitbucket decorator defaults to returning no URL since the details are not readily available, so Bitbucket Pull Requests will continue to show no link back the the Pull Request from Sonarqube.
mc1arke added a commit that referenced this issue May 31, 2020
Sonarqube provides the ability to link back to the original Pull Request or Merge Request from the Pull Request overview screen if the Pull Request URL is persisted alongside the branch details. To allow this, decorators are now required to return a `DecorationResult` that contains an optional URL for the Pull Request's overview/summary page. The Gitlab and Github decorators have been updated to provide the new details, however the Bitbucket decorator defaults to returning no URL since the details are not readily available, so Bitbucket Pull Requests will continue to show no link back the the Pull Request from Sonarqube.
@mc1arke
Copy link
Owner

mc1arke commented May 31, 2020

Release in version 1.3.1

@mc1arke mc1arke closed this as completed May 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants