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

[BUG] 10.3 SQ + 1.18.0 plugin release "No branch exists in Sonarqube with the name" for a PR to non existing branch #854

Closed
kzhuklinets opened this issue Jan 5, 2024 · 9 comments
Labels
bug Something isn't working

Comments

@kzhuklinets
Copy link

Hi,

We use Azure DevOps and when we try to analyze a PR merge to a non-existing branch in SQ, we receive an error "No branch exists in Sonarqube with the name xxxx"

This is a check which exists here, in plugin: https://github.com/mc1arke/sonarqube-community-branch-plugin/blob/5e5ca504c435f5844f86feee02880469344c7de7/src/main/java/com/github/mc1arke/sonarqube/plugin/scanner/BranchConfigurationFactory.java#L50C31-L50C31

The branch really doesn't exist, so to make it works we had to run analyze on the branch itself and then - PR merge.

To Reproduce
Steps to reproduce the behavior:

  1. Make a PR to a non-existing branch in SQ

Expected behavior

  1. Non-existing branch is created automatically
  2. PR merge works without errors

Software Versions

  • SonarQube Version: 10.3
  • Plugin Version: 1.18.0

Additional context
We haven't faced with it before (we are using SQ CE versions 9.8, 9.9, 10 with the plugin for more then year), so it might be some missing functionality, but on the other hand the check tells that it is intendent. SQ documentation doesn't show anything useful for this case.

@kzhuklinets kzhuklinets added the bug Something isn't working label Jan 5, 2024
@mc1arke
Copy link
Owner

mc1arke commented Jan 5, 2024

This is intentional under #847 as part of #738: if we don't have the reference branch then we can't correctly report issues. We can't just create the missing branch as we don't know what it contains.

@mc1arke mc1arke closed this as completed Jan 5, 2024
@jeremytbrun
Copy link

@mc1arke I'm having a similar issue when running a PR build but I've verified that the "master" branch exists in the SonarQube project. Any suggestions on how to fix this?

image

image

@jeremytbrun
Copy link

According to the code in the Sonar Scanner VSTS extension it is pulling the target branch name from System.PullRequest.TargetBranch and should be getting a substring that excludes "refs/heads". Any ideas why since I updated to SonarQube 10.3 and the latest extension version it's giving me the errors above?

https://github.com/SonarSource/sonar-scanner-vsts/blob/663fb6e7add4fe5d5ed6ebbba024fdc1e81672d6/common/ts/prepare-task.ts#L74C5-L74C101

@jeremytbrun
Copy link

I found that my issue was caused by build pipelines running older versions of the SonarQubePrepare, SonarQubeAnalyze, and SonarQubePublish VSTS pipelines tasks. By updating them to v5 tasks it resolved the issue.

SonarQubePrepare@5
SonarQubeAnalyze@5
SonarQubePublish@5

@jovanz-getbgd
Copy link

This is intentional under #847 as part of #738: if we don't have the reference branch then we can't correctly report issues. We can't just create the missing branch as we don't know what it contains.

How did this work correctly in previous versions then? The situation we have is not related to project creation, the project and its master and dev branches exist in SQ and are analyzed regularly, we are getting this issue when we try to do a PR into a temp release or hotfix branch.

I would consider this a breaking change for the plugin, which is not indicated by only increasing the minor release version.

@mc1arke
Copy link
Owner

mc1arke commented Jan 19, 2024

@jovanz-getbgd it defaulted to using your project's 'default' branch as the reference branch. This meant that the baselines were incorrect and Sonarqube was reporting misleading reference information. It may cause problems in workflows that haven't pre-scanned target branches, but I wouldn't class it as a breaking change since the process wasn't working properly for those scans anyway.

@jovanz-getbgd
Copy link

Thanks so much for a detailed explanation. Makes total sense now.

@fourirakbar
Copy link

fourirakbar commented May 10, 2024

I found that my issue was caused by build pipelines running older versions of the SonarQubePrepare, SonarQubeAnalyze, and SonarQubePublish VSTS pipelines tasks. By updating them to v5 tasks it resolved the issue.

SonarQubePrepare@5 SonarQubeAnalyze@5 SonarQubePublish@5

hi @jeremytbrun , I wanna ask how you solve this issue? because I face it now. I use
sonarqube -> 10.3.0-community using helm chart
sonarqube community branch plugin -> 1.18.0
sonar scanner maven version -> 3.11.0.3922

I'm a bit confused, where can i update this to v5?
SonarQubePrepare@5
SonarQubeAnalyze@5
SonarQubePublish@5

@hballangan-mdsol
Copy link

Same issue faced when opening PRs against release branches. Before we were able to analyze new PRs against a release branch but now with the new version it isn't possible. I think the old function was actually helpful as we were able to analyze bugfixes or additional features.

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

6 participants