SonarQube error: You're not authorized to run analysis, despite passing the token with build cmd

I’m trying to build a java maven project, but I’m getting [ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin: (default-cli) on project proj: You’re not authorized to run analysis. Please contact the project administrator. → [Help 1], even though I’m explicitly passing the url and access token along with maven command build.

Build command used: mvn clean install -Dmaven.test.skip=true sonar:sonar -Dsonar.login=token


# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:

- none

  vmImage: windows-latest
  name: custom_network

- task: SonarQubePrepare@5
    SonarQube: 'project-sonarqube'
    scannerMode: 'Other'

- task: MavenAuthenticate@0
    artifactsFeeds: 'Proj_Artifacts'

- task: Maven@4
    mavenPomFile: 'pom.xml'
    goals: 'clean install -Dmaven.test.skip=true sonar:sonar -Dsonar.login=token'
    publishJUnitResults: false
    testResultsFiles: '**/surefire-reports/TEST-*.xml'
    javaHomeOption: 'JDKVersion'
    jdkVersionOption: '1.8'
    mavenVersionOption: 'Default'
    mavenAuthenticateFeed: true
    effectivePomSkip: false
    sonarQubeRunAnalysis: true

- task: SonarQubePublish@5
    pollingTimeoutSec: '300'

ganncamp do you have any idea. I followed this comment of yours, where explicitly passing the token solved the issue. But my issue is still present even after explicitly passing the sonarqube token along with the maven build command.

I tried following this comment but even after sending sonarqube token along with the mvn build command as suggested by the comment I am still getting the error.


Welcome to the community!

Is this literally how your pipeline is configured?

Instead of literally passing “token” you need to create an analysis token and pass its value, either directly or via an interpolated variable.


Thank you Ann,

I think what you are saying about analysis token is a security feature and it won’t fix the error.

The error is fixed, it seems that while running azure pipeline build for a maven java project, one needs to send all the sonarqube parameters including project name and project key along with the build command.

goals: ‘clean install
-Dmaven.test.skip=true sonar:sonar

This above command is working fine.

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