We activated SonarCloud on our github repository some months ago
We have our main branch (called main, where we merge PR from feature branches
We have maintenance branch (called 2023.1.x, 2023.2.x, …) where we backport some bugfixes (cherry pick of commit from main to the maintenance branch)
Sonar detected our main banch as Long-lived and the maintenance branch as Short-lived
We do not really care as we only monitor quality gate from main branch
Until now everything was fine but today someone used a PR to backport a bug in 2023.1 (instead of direct cherry picking), and it seems it messed up sonar analysis. Now we have old bugs/vulnerabilities from 2023.1 branch reported in main (things we already fixed in main, so the report is not relevant anymore) .
Since we have PR pushed in main, report comes back to normal but we may have the issue back if someone merge a PR in 2023 branch. You can see in evolution strange things:
I wonder if more is getting merged into your your main branch when doing the PR from your maintenance branch than you expect
Otherwise, somehow the GitHub action being executed on your maintenance branch and sonar.branch.name is being defaulted to main.
Can you provide the logs from a GitHub Actions run where the wrong commit is analyzed as being on the main branch in SonarCloud? I can open a private message channel if needed.
Unfortunately I lost access to logs of last github action where we faced this (PR on maintenance are not so frequent), they purge logs.
Just to clarify we do not merge PR from maintenance into main, it is the opposite, we always commit in main, then cherry pick commits directly in maintenance branch, except in case of conflicts, where we create a work branch from maintenance branch, cherry pick the commit in work branch, resolve conflicts and open PR from work branch to merge it into maintenance branch (this is this particular workflow which seems to cause the issue)
As soon as you have another PR with this issue, please save the logs and provide them here or via a private message! That will be the best way to understand what’s going on.
Hello, Colin
I just did a trivial direct commit without PR on the maintenance branch. No action was launch from this commit, but still sonar, failed our quality gate on main with scan result from the maintenance branch instead.
I have no log as no github action runs