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

SQ 10.3.0-community + plugin 1.18.0 got error "No branch exists in Sonarqube with the name" #909

Open
fourirakbar opened this issue May 10, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@fourirakbar
Copy link

fourirakbar commented May 10, 2024

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

  1. Make a PR to a non-existing branch in SQ, let's say to branch "develop"

Expected behavior

  1. Non-existing branch (develop) is created automatically in SQ
  2. There is no error "No branch exists in Sonarqube with the name"

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.

@fourirakbar fourirakbar added the bug Something isn't working label May 10, 2024
@fourirakbar fourirakbar changed the title SQ 10.3.0-community + plugin 1.18.0 got errpr "No branch exists in Sonarqube with the name" SQ 10.3.0-community + plugin 1.18.0 got error "No branch exists in Sonarqube with the name" May 10, 2024
@hballangan-mdsol
Copy link

hballangan-mdsol commented May 22, 2024

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

name: CI - Test Automation
on:
  workflow_dispatch:
  push:             
    branches:
      - develop
  pull_request:

Our CI so that we don't get affected by the new feature (we have to remove on push develop):

name: CI - Test Automation
on:
  workflow_dispatch:
  pull_request:

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.

@hballangan-mdsol
Copy link

hballangan-mdsol commented May 22, 2024

For those encountering this issue on Github actions, a workaround is to add workflow dispatch:

on:
  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.

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

2 participants