mikepenz / action-junit-report

Reports junit test results as GitHub Pull Request Check
https://blog.mikepenz.dev
Apache License 2.0
298 stars 114 forks source link

Failed to create checks using the provided token. #1126

Closed saisanthoshkonduri closed 3 weeks ago

saisanthoshkonduri commented 2 months ago

I have passed the correct GITHUB_TOKEN. The project is Maven. Is it compatible with Maven? It is causing the issue below. Could you please help me here?

This is the codeblock,

    name: Build and analyze
    env:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}  # Needed to get PR information, if any
      SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
      SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
    run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.qualitygate.wait=true -Dsonar.coverage.jacoco.xmlReportPaths=target/site/jacoco/jacoco.xml sonar:sonar -Dsonar.projectKey=XYZ

    name: Publish Test Report
    uses: mikepenz/action-junit-report@v4
    env:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    if: success() || failure()
    with:
      report_paths: 'target/site/jacoco/jacoco.xml'

sonar

mikepenz commented 2 months ago

Please verify the token has the correct permission: https://github.com/mikepenz/action-junit-report?tab=readme-ov-file#pr-run-permissions

saisanthoshkonduri commented 2 months ago

Yes, that's the org-level token, and it has all the required permissions.

mikepenz commented 2 months ago

So your build does include?

permissions:
  checks: write

The error from the screenshot indicates that the provided token does not have the permission to crate those annotations, indicating the token needs higher priviledges

saisanthoshkonduri commented 2 months ago

No, where can I include it in the Maven project?

mikepenz commented 2 months ago

Please check the README: https://github.com/mikepenz/action-junit-report?tab=readme-ov-file#pr-run-permissions

It links to GitHub's documentation for more information on the permissions of the tokens. and why this is necessary.