Getting 401 unauthorized in my Jenkins pipeline script, but when I access it manually I am able to click the report with out any issues

I am getting below error as 401 Unauthorized while access quality Gate

[Pipeline] waitForQualityGate **10:11:24** Checking status of SonarQube task 'Task ID' on server 'SonarQube' [Pipeline] } [Pipeline] // script [Pipeline] } [Pipeline] // stage [Pipeline] echo **10:11:25** Failed on sonarQube - Error 401 on http://IPAddress:9000/api/ce/task?id=Task ID :

I am using SonarQube Scanner2.11 Jenkins Plugin
Running Jenkins Version - Jenkins 2.240

Here is the pipeline snippet

stage(‘Scan’) {
withSonarQubeEnv(‘SonarQube’) {
sh ‘sbt scalastyleGenerateConfig’
sh ‘sbt scalastyle’
sh ‘sbt coverageReport’
//sh ‘cp ~/ .’
sh ‘sbt sonar’
script {
def qg = waitForQualityGate()
if (qg.status != ‘OK’) {
error “Pipeline aborted due to quality gate failure: ${qg.status}”

Screenshot of globally set Auth token.

Here is the screenshot for the results if I access manually.


Welcome to the community!

What’s your version of SonarQube? And can you verify that you’ve actually set an analysis token in your global configuration?


Hello Ann,

Thanks for responding.

here are the details you looking for.
Community Edition
Version 7.9.3 (build 33349)

Please let me know if anything missing or needed, Thank you


Your screenshots show that you have created a token. What I’m asking is whether you’ve configured (no, don’t show me! just look for yourself :smiley:) that token in the Jenkins global config.

From the screenshot in your OP, it looks like you might not have done that configuration, but I’m no longer familiar with the current Jenkins UI.