Manual SonarScan doesn't update Main Branch but it's working on PR's

Template for a good new topic, formatted with Markdown:

  • ALM used (GitHub, Bitbucket Cloud, Azure DevOps): Github
  • CI system used (Bitbucket Cloud, Azure DevOps, Travis CI, Circle CI: Github actions
  • Scanner command used when applicable (private details masked): just the normal ones
  • Languages of the repository: JS/TS
  • Only if the SonarCloud project is public, the URL
    • And if you need help with pull request decoration, then the URL to the PR too
  • Error observed (wrap logs/code around with triple quotes ``` for proper formatting):
  • Not error shown, it passes Successful the scan of the lcov. After that, the main branch is still not updated.
  • Steps to reproduce:
    We have the analysis on PR, when the analysis it’s done, we merged to our main branch. That main branch doesn’t update since we changed the “automatic scan” to “manual scan” to add the coverage for our app.
  • Potential workaround:

Hey there.

Is the GitHub action responsible for SonarCloud analysis actually running on the main branch of your project?

Do you see a log message at the end indicating the report was successfully submitted?

2021-11-24T13:43:50.4169506Z INFO: Analysis report generated in 2611ms, dir size=27 MB
2021-11-24T13:43:51.4971165Z INFO: Analysis report compressed in 1079ms, zip size=3 MB
2021-11-24T13:43:52.4319069Z INFO: Analysis report uploaded in 932ms
2021-11-24T13:43:52.4336218Z INFO: ANALYSIS SUCCESSFUL, you can find the results at: https://sonarcloud.io/dashboard?id=colin-mueller-sonarsource_esp-at&branch=master
2021-11-24T13:43:52.4339517Z INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
2021-11-24T13:43:52.4342592Z INFO: More about the report processing at https://sonarcloud.io/api/ce/task?id=AX1SMDrHUAdr5IIhH9zC
2021-11-24T13:43:57.9408399Z INFO: Analysis total time: 59.457 s
2021-11-24T13:43:57.9422295Z INFO: ------------------------------------------------------------------------
2021-11-24T13:43:57.9423530Z INFO: EXECUTION SUCCESS
2021-11-24T13:43:57.9424889Z INFO: ------------------------------------------------------------------------

hey @Colin. This action is only fired when we do PR’s to our “main branch”, but not when we merge them. I don’t know if this is what u asked.
This log message, yeah it shows like this. Also, on Sonarcloud I can see the branches passing the analysis.

Hey there.

In that case, you’ve really answered your own question – you need to make sure the action runs whenever there’s a new commit on your main branch. A basic GitHub action that accomplishes this looks like this (and is the example given in the UI tutorial)

name: Build
on:
  push:
    branches:
      - main
  pull_request:
    types: [opened, synchronize, reopened]
jobs:
  sonarcloud:
    name: SonarCloud
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0  # Shallow clones should be disabled for a better relevancy of analysis
      - name: SonarCloud Scan
        uses: SonarSource/sonarcloud-github-action@master
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}  # Needed to get PR information, if any
          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

Oh! Nice!! I’ll try it :slight_smile: Thanks!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.