403 when trying to publish analysis report from Jenkinsfile

Hi, I’m running into an issue running SonarScans. The analyze step seems to run just fine, but when it comes time to upload the report, I get a 403 (which results in the error “You’re not authorized to run analysis”, which I do not think is correct).

  • ALM: GitHub
  • CI system: Jenkins (using a declarative pipeline)
  • Scanner command used:
stage('SonarQube analysis') {
    environment {
        SCANNER_HOME = tool 'SonarScanner'
        ORGANIZATION = "redacted"
        PROJECT_NAME = "redacted"
        TOKEN = credentials('SonarCloud-Token')
    }
    steps {
        withSonarQubeEnv('SonarQube') {
            sh '''
                ${SCANNER_HOME}/bin/sonar-scanner -X \
                    -Dsonar.organization=$ORGANIZATION \
                    -Dsonar.projectKey=$PROJECT_NAME \
                    -Dsonar.login=$TOKEN \
                    -Dsonar.inclusions="**/*.php" \
                    -Dsonar.exclusions="**/vendor,**/cache,**/log"
            '''
        }
    }

  • Languages of the repository: PHP
  • Error observed:
...
18:03:31.869 DEBUG: Detection of duplications for /var/lib/jenkins/workspace/GD-17360-sonar-scanner/wall/lib/Wall/Entity/InviteCode.php
18:03:31.869 INFO: CPD Executor CPD calculation finished (done) | time=161ms
18:03:32.123 INFO: Analysis report generated in 213ms, dir size=4 MB
18:03:33.248 INFO: Analysis report compressed in 1125ms, zip size=2 MB
18:03:33.248 INFO: Analysis report generated in /var/lib/jenkins/workspace/GD-17360-sonar-scanner/.scannerwork/scanner-report
18:03:33.248 DEBUG: Upload report
18:03:34.171 DEBUG: POST 403 https://sonarcloud.io/api/ce/submit?organization=redacted&projectKey=redacted | time=922ms
18:03:34.177 DEBUG: stylelint-bridge server will shutdown
18:03:34.181 INFO: ------------------------------------------------------------------------
18:03:34.181 INFO: EXECUTION FAILURE
18:03:34.181 INFO: ------------------------------------------------------------------------
18:03:34.181 INFO: Total time: 1:05.093s
18:03:34.381 INFO: Final Memory: 63M/1522M
18:03:34.381 INFO: ------------------------------------------------------------------------
18:03:34.381 ERROR: Error during SonarScanner execution
You're not authorized to run analysis. Please contact the project administrator.
script returned exit code 2

Thank you in advance for your help!

Hi @amacrobert-meq,

Could you double check that the token you pass to the scanner is correct and belongs to a user that has the SCAN permission on the project you’re trying to scan?