Why is default workflow failing?

Template for a good new topic, formatted with Markdown:

  • ALM used (GitHub)
  • CI system used (GH Actions)
  • Languages of the repository (C#)
  • Error observed (wrap logs/code around with triple quotes ``` for proper formatting)
INFO: ------------------------------------------------------------------------
INFO: ------------------------------------------------------------------------
INFO: Total time: 34.191s
INFO: Final Memory: 20M/70M
ERROR: Error during SonarScanner execution
ERROR: Could not find the pullrequest with key '21'
INFO: ------------------------------------------------------------------------
ERROR: Caused by: Error 404 on https://sonarcloud.io/api/alm_integration/show_pullrequest?project=DYMSA-ING_Sistema-Visitantes&pullrequestKey=21 : {"errors":[{"msg":"The pullrequest could not be found"}]}
The SonarScanner did not complete successfully
13:04:37.779  Post-processing failed. Exit code: 1
Error: Process completed with exit code 1.
  • Steps to reproduce:
  • Purchase SonarCloud
  • Link to GitHub repository
  • Do the quick setup steps
  • PR to the branch
  • Failed

I have checked that the PR exists. Tried multiple times with different PRs and fails anyway. I have only changed the triggers and the “insert command here” section. What am I doing wrong? Help pls.

(There are 2 .NET projects, one called Web and one called API, both commands work just fine in console).

Here is my sonarcloud.yml file:

      - master
      - prod
    name: Build and analyze
    runs-on: windows-latest
      - name: Set up JDK 11
        uses: actions/setup-java@v3
          java-version: 11
          distribution: 'zulu' # Alternative distribution options are available.
      - uses: actions/checkout@v3
          fetch-depth: 0  # Shallow clones should be disabled for a better relevancy of analysis
      - name: Cache SonarCloud packages
        uses: actions/cache@v3
          path: ~\sonar\cache
          key: ${{ runner.os }}-sonar
          restore-keys: ${{ runner.os }}-sonar
      - name: Cache SonarCloud scanner
        id: cache-sonar-scanner
        uses: actions/cache@v3
          path: .\.sonar\scanner
          key: ${{ runner.os }}-sonar-scanner
          restore-keys: ${{ runner.os }}-sonar-scanner
      - name: Install SonarCloud scanner
        if: steps.cache-sonar-scanner.outputs.cache-hit != 'true'
        shell: powershell
        run: |
          New-Item -Path .\.sonar\scanner -ItemType Directory
          dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner
      - name: Build and analyze
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}  # Needed to get PR information, if any
          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
        shell: powershell
        run: |
          .\.sonar\scanner\dotnet-sonarscanner begin /k:"DYMSA-ING_Sistema-Visitantes" /o:"dymsa-ing" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io"
          dotnet build api
          dotnet build web
          .\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"```

Hello @je-sendra,

Typically this looks like a permission issue and can be related to the GITHUB_TOKEN in your analysis environment. Make sure the token has sufficient access the the repo in question. Also double check if you have set up the SONAR_TOKEN correctly.


I have the SONAR_TOKEN setup correctly, but I don’t know anything about the GITHUB_TOKEN. What is the analysis environment?

I used Github to login to sonarcloud and imported the organization directly

Hi @je-sendra,

I have passed along the difficulty to the documentation team to be more explicit about GITHUB_TOKEN in our docs and tutorial.

You need to use read permission for pull_requests for the GITHUB_TOKEN. This allows us to determine on which PR you are running the action to be able to decorate them. You need to add the following lines to your sonarcloud.yml file.

  pull-requests: read # allows SonarCloud to decorate PRs with analysis results

You can read more about GITHUB_TOKEN here. Hope it helps.


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