# SonarQube on CodeBuild not reporting analysis results

**URL:** <https://community.sonarsource.com/t/sonarqube-on-codebuild-not-reporting-analysis-results/134812>\
**Category:** SonarQube Cloud\
**Created:** [February 7, 2025, 9:16pm UTC](https://community.sonarsource.com/t/sonarqube-on-codebuild-not-reporting-analysis-results/134812 "2025-02-07T21:16:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrew\_Burnett](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/andrew_burnett/32/66602_2.png) [@Andrew\_Burnett](https://community.sonarsource.com/u/Andrew_Burnett)\
**Post date:** [February 7, 2025, 9:16pm UTC](https://community.sonarsource.com/t/sonarqube-on-codebuild-not-reporting-analysis-results/134812/1 "2025-02-07T21:16:21Z")

</div>

- ALM used: Github
- CI system used: Github Actions
- Scanner command used when applicable: sonarqube action for Github Actions
- Languages of the repository: js/ts/ruby
- Error observed: Sonar analysis is not reported
- Steps to reproduce: Run SonarQube action on AWS CodeBuild self-hosted Github Actions runners
- Potential workaround: N/A

We are attempting to run the SonarQube Github Action: [GitHub - SonarSource/sonarqube-scan-action](https://github.com/SonarSource/sonarqube-scan-action)

When running on a standard 8 core Ubuntu runner from Github itself, everything runs fine. We can also run on a now deprecated Philips-Labs self-hosted runner. Both of these CI environments will produce a report in our Sonar UI and post a comment on the PR with analysis information to Github.

Simply running on an AWS CodeBuild runner is enough to break the reporting process. None of the runs, reports, or even PR branches will show in the Sonar UI when run via CodeBuild. In the log output, `ANALYSIS SUCCESSFUL` link will have the org and repo name, but lack the pull request context that _does_ show up on other runner flavors. Seemingly related issue and possible workaround: [SonarCloud PullRequest analysis not working - #4 by Parasappa\_Yaragal](https://community.sonarsource.com/t/sonarcloud-pullrequest-analysis-not-working/127365/4)

We tried unsetting these environment variables, as well as _all_ `CODEBUILD_` variables in various iterations. Nothing seems to change the behavior.

Any insights welcome. 🙏

---

<div class="post-metadata">

**Author:** ![Colin](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/colin/32/55255_2.png) [@Colin](https://community.sonarsource.com/u/Colin)\
**Post date:** [February 10, 2025, 11:29am UTC](https://community.sonarsource.com/t/sonarqube-on-codebuild-not-reporting-analysis-results/134812/2 "2025-02-10T11:29:25Z")

</div>

Hey there.

This also sounds a bit like [this issue](https://community.sonarsource.com/t/pull-request-analysis-is-no-longer-working/134515/12).

To try and state the situation briefly:

- Automatic detection of PR parameters in a GitHub Actions environment relies on the presence of a `GITHUB_ACTIONS` environment variable
- The scanner does no automatic inference of PR parameters when AWS CodeBuild is detected (presence of `CODEBUILD_BUILD_ID` and `CODEBUILD_START_TIME`)
- Frustratingly, as found in [this post that you noted](https://community.sonarsource.com/t/sonarcloud-pullrequest-analysis-not-working/127365/4), if multiple CI environments are detected the autoconfiguration gives up

To be honest, I’m not familiar at all with AWS Code Build runners (until today I thought AWS Code Build and GitHub Actions were very distinct platforms). [You learn something new everyday.](https://docs.aws.amazon.com/codebuild/latest/userguide/action-runner.html)

You may find it easiest to simply [provide the PR parameters on your own](https://docs.sonarsource.com/sonarqube-cloud/advanced-setup/analysis-parameters/#pull-request-analysis).

**Or,** give a try configuring the `GITHUB_ACTIONS` environment variable to a value while unsettling `CODEBUILD_BUILD_ID` and `CODEBUILD_START_TIME`.

None of these are ideal, and I’ll flag this for attention as a confusing user experience!

---

<div class="post-metadata">

**Author:** ![Andrew\_Burnett](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/andrew_burnett/32/66602_2.png) [@Andrew\_Burnett](https://community.sonarsource.com/u/Andrew_Burnett)\
**Post date:** [February 10, 2025, 9:53pm UTC](https://community.sonarsource.com/t/sonarqube-on-codebuild-not-reporting-analysis-results/134812/3 "2025-02-10T21:53:53Z")

</div>

Providing the PR parameters appears to do the trick. By passing the following to the SonarQube Github Action we are successfully getting analysis results on CodeBuild runs:

```auto
...
- name: SonarCloud Scan
      uses: SonarSource/sonarqube-scan-action@v4.2.1
      env:
        GITHUB_TOKEN: ${{ inputs.github-token-for-sonar }}
        SONAR_TOKEN: ${{ inputs.sonar-cloud-token }}
      with:
        args: >
          ...
          -Dsonar.pullrequest.key=${{ github.event.pull_request.number || github.event.issue.number }}
          -Dsonar.pullrequest.branch=${{ github.head_ref || github.ref_name }}
          -Dsonar.pullrequest.base=${{ github.event.repository.default_branch }}
...

```

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/system/32/31083_2.png) [@system](https://community.sonarsource.com/u/system)\
**Post date:** [February 21, 2025, 5:15pm UTC](https://community.sonarsource.com/t/sonarqube-on-codebuild-not-reporting-analysis-results/134812/6 "2025-02-21T17:15:52Z")

</div>

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