Skip to content

Add pull-requests: write permission to SonarCloud workflow#60

Merged
304NotModified merged 2 commits intomainfrom
copilot/fix-sonarcloud-permissions
Apr 6, 2026
Merged

Add pull-requests: write permission to SonarCloud workflow#60
304NotModified merged 2 commits intomainfrom
copilot/fix-sonarcloud-permissions

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 6, 2026

SonarCloud cannot post analysis results on PRs without the pull-requests: write permission, causing silent failures on PR analysis.

Change

  • Added pull-requests: write to the sonarcloud job's permissions block in .github/workflows/sonarcloud.yml
permissions:
  contents: read
  id-token: write
  pull-requests: write  # added
Original prompt

Problem

SonarCloud does not report analysis results on pull requests because the workflow in .github/workflows/sonarcloud.yml is missing the pull-requests: write permission. Without this permission, SonarCloud cannot post comments or status updates on PRs.

This is tracked in issue #59: #59

Fix

In .github/workflows/sonarcloud.yml, add pull-requests: write to the permissions block of the sonarcloud job:

    permissions:
      contents: read
      id-token: write
      pull-requests: write   # add this line

The current permissions block is at lines 13–15. No other changes are needed.

The following is the prior conversation context from the user's chat exploration (may be truncated):

User: Ik heb dit probleem. Kan ik dit fixen zodat dat sq zomaar code enzo kan pushen? @304NotModified/SLNX-validator/issues/59

Assistant: Het probleem is duidelijk: SonarCloud rapporteert niet op pull requests omdat de workflow onvoldoende permissies heeft. Dit is een bekende beperking van SonarCloud met GitHub Actions.

Oorzaak

SonarCloud heeft de permissie pull-requests: write nodig om comments te kunnen plaatsen op een PR. Die ontbreekt nu in je workflow. Daarnaast is er nog een tweede probleem: bij PR's van forks heeft SonarCloud geen toegang tot secrets, maar dat speelt hier waarschijnlijk minder.

Fix

Voeg pull-requests: write toe aan de permissions in je sonarcloud.yml:

    permissions:
      contents: read
      id-token: write
      pull-requests: write   # ← dit toevoegen

Wil je dat ik een PR aanmaak om dit te fixen in 304NotModified/SLNX-validator?

User: Ja pr

Assistant: We wachten op jouw reactie op het dialoogvenster om verder te gaan met het aanmaken van de PR.

This pull request was created from Copilot chat.

Copilot AI changed the title [WIP] Add pull-requests: write permission in SonarCloud workflow Add pull-requests: write permission to SonarCloud workflow Apr 6, 2026
Copilot AI requested a review from 304NotModified April 6, 2026 10:08
@304NotModified 304NotModified linked an issue Apr 6, 2026 that may be closed by this pull request
@304NotModified 304NotModified marked this pull request as ready for review April 6, 2026 10:13
@304NotModified 304NotModified enabled auto-merge (squash) April 6, 2026 10:13
@304NotModified 304NotModified disabled auto-merge April 6, 2026 10:13
@304NotModified 304NotModified requested a review from Copilot April 6, 2026 10:14
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the SonarCloud GitHub Actions workflow to grant PR write permissions so analysis results can be reported back to pull requests.

Changes:

  • Added pull-requests: write to the sonarcloud job’s permissions block in the SonarCloud workflow.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@304NotModified 304NotModified merged commit a99e5aa into main Apr 6, 2026
10 checks passed
@304NotModified 304NotModified deleted the copilot/fix-sonarcloud-permissions branch April 6, 2026 10:42
@304NotModified 304NotModified added the build CI build stuff label Apr 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build CI build stuff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sonarqube won't report to pr

3 participants