-
-
Notifications
You must be signed in to change notification settings - Fork 528
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
SQ 10.3.0-community + plugin 1.18.0 got error "No branch exists in Sonarqube with the name" #909
Comments
@mc1arke having the same error. I would add that this issue raises more concerns as it's affecting a lot of repos doing lots of release and non-main branches. In the original feature we only have to address the issue once during project creation, which is easily mitigated with proper documentation and by following instructions on how to properly create a project. But now we will have to modify CI behavior and also address all new issues on creating new branch scan for each non-main/release branch. Our CI before the change:
Our CI so that we don't get affected by the new feature (we have to remove on push develop):
For us to create non-main branches, we now have to remove and let it run on all branches, which is a lot of wasted resources since we are already running on PR and also it will create a lot of useless branches (since we only need main, or release). Our last option is to totally disable code analysis if the target branch is NOT develop which is not ideal since we also want to analyse some custom or release branches OR add continue-on-error: true on Code analysis which will ignore underlying issues. Now I understand that the new feature added was to prevent errors at the start of code analysis if no main branch exists, but that error doesn't happen if the project has already been created and we just want to merge to custom branch. Maybe a workaround for this is to only reject on project creation (OR if target branch is main/develop/master) and accept PR analysis if project already exists. Why I suggest this is that we never encountered any error when project already exists. |
For those encountering this issue on Github actions, a workaround is to add workflow dispatch:
And manually trigger the Code Analysis Github Action on the non-main branch. You have to do this for all new non-main feature/release branch. |
Found that the feature for sonarqube includes autocreation of branches(see provision github projects with ease) when using the github action. So it is going against the direction of the upgrade if the community pull request is doing the opposite and restricting autocreation of branches |
@mc1arke Please let us know how to do workaround when using in github actions using sonarqube-scan-action and in circleci docker image. |
This is where the problem lies: the plugin (or Sonarqube) doesn't know what's on that branch, so can't realistically report new/changed issues.
I don't think the release note you've mentioned in your comment indicates anything about automatic creation of branches - only that Sonarqube will automatically configure project details (branch name and pull request decoration) for you. If you can show evidence that demonstrates automatic scanning of a target branches on submissions of a scan then I'll happily investigate how to make the plugin work in the same way, but the current implementation is as it is to prevent misleading scans being presented to users.
I'm presuming you're getting an error stating that |
The resolution of Pull Request details currently uses the project default branch when a pull request is analysed without specifying a target branch. However, when a target branch is specified, the plugin expects that branch to exist and throws an exception if the target branch is not found. To overcome this, the target branch is being resolved to the default branch where no target branch is specified or the requested target branch does not exist. As the API used to gather branch information does not return PULL_REQUEST details, the result of this searching is that a pull request will either target a branch from the main branch, or target the main branch, there is no further nesting or pull requests and branches.
… not exist (#15) The resolution of Pull Request details currently uses the project default branch when a pull request is analysed without specifying a target branch. However, when a target branch is specified, the plugin expects that branch to exist and throws an exception if the target branch is not found. To overcome this, the target branch is being resolved to the default branch where no target branch is specified or the requested target branch does not exist. As the API used to gather branch information does not return PULL_REQUEST details, the result of this searching is that a pull request will either target a branch from the main branch, or target the main branch, there is no further nesting or pull requests and branches. Co-authored-by: Michael Clarke <michael.m.clarke@gmail.com>
The resolution of Pull Request details currently uses the project default branch when a pull request is analysed without specifying a target branch. However, when a target branch is specified, the plugin expects that branch to exist and throws an exception if the target branch is not found. To overcome this, the target branch is being resolved to the default branch where no target branch is specified or the requested target branch does not exist. As the API used to gather branch information does not return PULL_REQUEST details, the result of this searching is that a pull request will either target a branch from the main branch, or target the main branch, there is no further nesting or pull requests and branches.
Describe the bug
We submit a PR to a branch that doesn't exist in SQ (but already exists in the GitHub repo). For example, in SQ only the "main" branch is listed, while we submit a PR to the "develop" branch. Then, we will get an error "No branch exists in Sonarqube with the name."
Previously, we used Sonarqube version 9.3.0-community and plugin 1.12.0, everything ran normally and there was no error like this.
To Reproduce
Expected behavior
Software Versions
SonarQube Version: 10.3.0-community using helm chart
Plugin Version: 1.18.0
Sonar maven scanner version: 3.11.0.3922
Additional context
My code uses Java Spring (Maven). Meanwhile, I can solve this by adding
<sonar.branch.name>develop</sonar.branch.name>
in the pom.xml. The effect is that the "develop" branch will appear in SQ. Then I must remove<sonar.branch.name>develop</sonar.branch.name>
from the pom.xml and make the PR again. This is quite inconvenient for us, because with the previous version I did not have to do this.My problem might be similar to #854, but I still don't quite understand how to fix it.
The text was updated successfully, but these errors were encountered: