SonarCloud configuration issue after branch restructure

Hello,

We have a repository setup on SonarCloud for analysis.

We have recently moved from one main branch to several branches.

We also move the HEAD to the branch next on github and sonar.

We now have lots of branches:

  • next (HEAD) [DEV]

  • main [PROD]

  • v* [VERSION]

  • and a lot of feature branches used to create the PRs

We want to analyse:

  • Pull Requests

  • Branch (after a merge)

Here are our issues:

  1. We cannot have the main branch in the long lived branches page

  2. The pull requests page only show PRs from before the change (1 month ago)

  3. Some feature branches are in the short lived branches (not sure if they should be there)

  4. I tried to add vars to the GitHub action, but to no success

  • Dsonar.branch.name=${{ github.event.pull_request.head.ref || github.ref_name }
  • Dsonar.branch.target=${{ github.event.pull_request.base.ref || ‘’ }}

Can you help us setup our Github Action workflow to get to result we’re expecting ?

Do you have any method for this type of workflow ?

## e2e.yaml


name: unit + sonar + e2e tests

on:

push:

branches:

        - main

        - next

        - 'v\*'

pull_request:

branches:

        - main

        - next

        - 'v\*'

types: \[opened, synchronize, reopened\]

jobs:

e2e-test:

        - ...

        - name: SonarCloud Scan

if: success()

continue-on-error: true

uses: SonarSource/sonarqube-scan-action@v5

env:

SONAR_TOKEN: ${{ secrets.SONARCLOUD_TOKEN }}

## sonar-project.properties


sonar.organization=bearingpoint

sonar.projectKey=bearingpoint_nitro

sonar.sources=apps/webapp/,apps/webapi/,apps/webworker/,libs/webapp/,libs/webapi/

sonar.javascript.lcov.reportPaths=coverage/\*\*/lcov.info,cypress/coverage/lcov.info

sonar.exclusion=.dev-env/\*\*/\*,\*\*/entities/\*\*/\*,\*\*/migrations/\*\*/\*,\*\*/dtos/\*\*/\*,apps/\*-e2e/\*\*/\*,apps/\*-python/\*\*/\*,libs/webapp/open-api/\*\*/\*,libs/hdp-lib-api/\*\*/\*,libs/shared/\*\*/\*

Regards.

Hi,

Welcome to the community!

Both of these relate to your long-lived branch pattern which determines whether branches are recognized as long-lived or short-lived. Unfortunately, once this is determined for a branch, it’s immutable. So you’ll need to delete those branches, adjust your pattern (perhaps .* since you don’t seem to want any short-lived branches?) and re-analyze them.

We try to keep it to one topic per thread. Otherwise it can get messy, fast. And this sounds like a messy one, which is as likely to be about your CI as it is about SonarQube Cloud. If you’d like to pursue this, please create a new thread with the analysis log from a PR.

You shouldn’t need to do this. These values should be picked up automatically from your environment.

 
HTH,
Ann