WARN: Unable to locate 'report-task.txt' in the workspace. Did the SonarScanner succeed?

Must-share information (formatted with Markdown):
Hello guys,
I am using
Sonar Quebe=Community EditionVersion 8.5.1 (build 38104)
I have inetgrated sonar quebe with jenkins and with out quality gate analysis i am able to succeed the job , when i include the quality gate anlaysis it gails with error WARN: Unable to locate ‘report-task.txt’ in the workspace. Did the SonarScanner succeed?
I think report-task file is not being generated
this is the pipeline i am using
node
{
deleteDir()
stage(‘Pull Code from branch’)
{
git branch: ‘release’, url: ‘XXXXXXXXXXXXX’
}

stage('SonarQube analysis') {
withSonarQubeEnv() { // Will pick the global server connection you have configured
  sh "/var/lib/jenkins/sonar-scanner-4.6.0.2311-linux/bin/sonar-scanner \

-Dsonar.host.url=http://localhost:9000
-Dsonar.login=xxxxxx
-Dsonar.password=xxxxx
-Dsonar.projectBaseDir=/var/lib/jenkins/workspace/pipeline
-Dsonar.projectKey=any
-Dsonar.projectName=any
-Dsonar.projectVersion=1.0
-Dsonar.language=py
-Dsonar.sourceEncoding=UTF-8
-Dsonar.python.xunit.reportPath=nosetests.xml
-Dsonar.python.coverage.reportPath=coverage.xml
-Dsonar.sources=/var/lib/jenkins/workspace/pipeline"
}
}
stage(“Quality Gate 1”) {

        waitForQualityGate abortPipeline: true
        
}    

	}

I have reaserached and found that we can use
sonar.scanner.metadataFilePath= working directory(/var/lib/jenkins/workspace/pipeline)
but if i use this command it says unable to dump the data to /var/lib/jenkins/workspace/pipeline

Need your help in solving this.

You didn’t show any actual output from the sonar-scanner run. Some information there might be useful.

I note that the entire point of the “withSonarQubeEnv()” pipeline step is to send a string parameter to it which corresponds to the name of the SonarQube installation in the Jenkins config, which will result in environment variables being set corresponding to the url for that sonarqube instance, along with the required credentials for it. If that is properly set up, you should actually be able to remove the “sonar.host.url”, “sonar.login”, and “sonar.password” property settings, or at least to set them from the environment variables. I believe the SonarQube instance config allows configuring it for a “token” or “user/password”, and I’m only familiar with the token variation.

Hello David,

Thaks for your reply heres is the out put
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (SonarQube analysis)
[Pipeline] withSonarQubeEnv
Injecting SonarQube environment variables using the configuration: sonarquebe
[Pipeline] {
[Pipeline] sh

  • /var/lib/jenkins/sonar-scanner-4.6.0.2311-linux/bin/sonar-scanner -Dsonar.host.url=http://localhost:9000 -Dsonar.login=any -Dsonar.password=any -Dsonar.projectBaseDir=/var/lib/jenkins/workspace/pipeline/ -Dsonar.projectKey=XX -Dsonar.projectName=ANY -Dsonar.projectVersion=1.0 -Dsonar.language=py -Dsonar.sourceEncoding=UTF-8 -Dsonar.scanner.metadataFilePath=/var/lib/jenkins/workspace/pipeline/ -Dsonar.python.xunit.reportPath=nosetests.xml -Dsonar.python.coverage.reportPath=coverage.xml -Dsonar.sources=/var/lib/jenkins/workspace/pipeline/
    INFO: Scanner configuration file: /var/lib/jenkins/sonar-scanner-4.6.0.2311-linux/conf/sonar-scanner.properties
    INFO: Project root configuration file: NONE
    INFO: SonarScanner 4.6.0.2311
    INFO: Java 11.0.3 AdoptOpenJDK (64-bit)
    INFO: Linux 5.4.0-1045-aws amd64
    INFO: User cache: /var/lib/jenkins/.sonar/cache
    INFO: Scanner configuration file: /var/lib/jenkins/sonar-scanner-4.6.0.2311-linux/conf/sonar-scanner.properties
    INFO: Project root configuration file: NONE
    INFO: Analyzing on SonarQube server 8.5.1
    INFO: Default locale: “en”, source code encoding: “UTF-8”
    INFO: Load global settings
    INFO: Load global settings (done) | time=389ms
    INFO: Server id: 69510CB8-AXjquNZenphUyL2uhh56
    INFO: User cache: /var/lib/jenkins/.sonar/cache
    INFO: Load/download plugins
    INFO: Load plugins index
    INFO: Load plugins index (done) | time=360ms
    INFO: Load/download plugins (done) | time=448ms
    INFO: Process project properties
    INFO: Process project properties (done) | time=10ms
    INFO: Execute project builders
    INFO: Execute project builders (done) | time=2ms
    INFO: Project key: XX
    INFO: Base dir: /var/lib/jenkins/workspace/pipeline
    INFO: Working dir: /var/lib/jenkins/workspace/pipeline/.scannerwork
    INFO: Load project settings for component key: ‘XX’
    INFO: Load project settings for component key: ‘XX’ (done) | time=339ms
    INFO: Load quality profiles
    INFO: Load quality profiles (done) | time=371ms
    INFO: Auto-configuring with CI ‘Jenkins’
    INFO: Load active rules
    INFO: Load active rules (done) | time=6073ms
    WARN: SCM provider autodetection failed. Please use “sonar.scm.provider” to define SCM of your project, or disable the SCM Sensor in the project settings.
    INFO: Indexing files…
    INFO: Project configuration:
    INFO: 1 file indexed
    INFO: ------------- Run sensors on module xxxxxxx
    INFO: Load metrics repository
    INFO: Load metrics repository (done) | time=427ms
    INFO: Sensor CSS Rules [cssfamily]
    INFO: No CSS, PHP, HTML or VueJS files are found in the project. CSS analysis is skipped.
    INFO: Sensor CSS Rules [cssfamily] (done) | time=1ms
    INFO: Sensor JaCoCo XML Report Importer [jacoco]
    INFO: ‘sonar.coverage.jacoco.xmlReportPaths’ is not defined. Using default locations: target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml,build/reports/jacoco/test/jacocoTestReport.xml
    INFO: No report imported, no coverage information will be imported by JaCoCo XML Report Importer
    INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=4ms
    INFO: Sensor C# Properties [csharp]
    INFO: Sensor C# Properties [csharp] (done) | time=1ms
    INFO: Sensor JavaXmlSensor [java]
    INFO: Sensor JavaXmlSensor [java] (done) | time=1ms
    INFO: Sensor HTML [web]
    INFO: Sensor HTML [web] (done) | time=3ms
    INFO: Sensor VB.NET Properties [vbnet]
    INFO: Sensor VB.NET Properties [vbnet] (done) | time=2ms
    INFO: ------------- Run sensors on project
    INFO: Sensor Zero Coverage Sensor
    INFO: Sensor Zero Coverage Sensor (done) | time=1ms
    INFO: SCM Publisher No SCM system was detected. You can use the ‘sonar.scm.provider’ property to explicitly specify it.
    INFO: CPD Executor Calculating CPD for 0 files
    INFO: CPD Executor CPD calculation finished (done) | time=0ms
    INFO: Analysis report generated in 131ms, dir size=82 KB
    INFO: Analysis report compressed in 14ms, zip size=10 KB
    INFO: Analysis report uploaded in 330ms
    INFO: ------------------------------------------------------------------------
    INFO: EXECUTION FAILURE
    INFO: ------------------------------------------------------------------------
    INFO: Total time: 11.925s
    INFO: Final Memory: 6M/27M
    INFO: ------------------------------------------------------------------------
    ERROR: Error during SonarScanner execution
    java.lang.IllegalStateException: Unable to dump /var/lib/jenkins/workspace/pipeline
    at org.sonar.scanner.report.ReportPublisher.dumpMetadata(ReportPublisher.java:314)
    at org.sonar.scanner.report.ReportPublisher.prepareAndDumpMetadata(ReportPublisher.java:241)
    at org.sonar.scanner.report.ReportPublisher.execute(ReportPublisher.java:143)
    at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:366)
    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
    at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:144)
    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
    at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:72)
    at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:66)
    at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.base/java.lang.reflect.Method.invoke(Unknown Source)
    at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
    at com.sun.proxy.$Proxy0.execute(Unknown Source)
    at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:189)
    at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)
    at org.sonarsource.scanner.cli.Main.execute(Main.java:112)
    at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
    at org.sonarsource.scanner.cli.Main.main(Main.java:61)
    Caused by: java.nio.file.FileSystemException: /var/lib/jenkins/workspace/CP-pipeline: Is a directory
    at java.base/sun.nio.fs.UnixException.translateToIOException(Unknown Source)
    at java.base/sun.nio.fs.UnixException.rethrowAsIOException(Unknown Source)
    at java.base/sun.nio.fs.UnixException.rethrowAsIOException(Unknown Source)
    at java.base/sun.nio.fs.UnixFileSystemProvider.newByteChannel(Unknown Source)
    at java.base/java.nio.file.spi.FileSystemProvider.newOutputStream(Unknown Source)
    at java.base/java.nio.file.Files.newOutputStream(Unknown Source)
    at java.base/java.nio.file.Files.newBufferedWriter(Unknown Source)
    at org.sonar.scanner.report.ReportPublisher.dumpMetadata(ReportPublisher.java:303)
    … 22 more
    ERROR:
    ERROR: Re-run SonarScanner using the -X switch to enable full debug logging.
    [Pipeline] }
    WARN: Unable to locate ‘report-task.txt’ in the workspace. Did the SonarScanner succeed?

This is the error when i use sonar.scanner.metadataFilePath = working directory(/var/lib/jenkins/workspace/pipeline)

and if dont declare that in pipeline sonar qube analysis done but failed at Qualitygate analysis

[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (SonarQube analysis)
[Pipeline] withSonarQubeEnv
Injecting SonarQube environment variables using the configuration: sonarquebe
[Pipeline] {
[Pipeline] sh

  • /var/lib/jenkins/sonar-scanner-4.6.0.2311-linux/bin/sonar-scanner -Dsonar.host.url=http://localhost:9000 -Dsonar.login=any -Dsonar.password=any -Dsonar.projectBaseDir=/var/lib/jenkins/workspace/pipeline/ -Dsonar.projectKey=XX -Dsonar.projectName=ANY -Dsonar.projectVersion=1.0 -Dsonar.language=py -Dsonar.sourceEncoding=UTF-8 -
    Dsonar.python.xunit.reportPath=nosetests.xml -Dsonar.python.coverage.reportPath=coverage.xml -Dsonar.sources=/var/lib/jenkins/workspace/pipeline/
    INFO: Scanner configuration file: /var/lib/jenkins/sonar-scanner-4.6.0.2311-linux/conf/sonar-scanner.properties
    pipeline/ -Dsonar.python.xunit.reportPath=nosetests.xml -Dsonar.python.coverage.reportPath=coverage.xml -Dsonar.sources=/var/lib/jenkins/workspace/pipeline/
    INFO: Scanner configuration file: /var/lib/jenkins/sonar-scanner-4.6.0.2311-linux/conf/sonar-scanner.properties
    INFO: Project root configuration file: NONE
    INFO: SonarScanner 4.6.0.2311
    INFO: Java 11.0.3 AdoptOpenJDK (64-bit)
    INFO: Linux 5.4.0-1045-aws amd64
    INFO: User cache: /var/lib/jenkins/.sonar/cache
    INFO: Scanner configuration file: /var/lib/jenkins/sonar-scanner-4.6.0.2311-linux/conf/sonar-scanner.properties
    INFO: Project root configuration file: NONE
    INFO: Analyzing on SonarQube server 8.5.1
    INFO: Default locale: “en”, source code encoding: “UTF-8”
    INFO: Load global settings
    INFO: Load global settings (done) | time=382ms
    INFO: Server id: 69510CB8-AXjquNZenphUyL2uhh56
    INFO: User cache: /var/lib/jenkins/.sonar/cache
    INFO: Load/download plugins
    INFO: Load plugins index
    INFO: Load plugins index (done) | time=365ms
    INFO: Load/download plugins (done) | time=459ms
    INFO: Process project properties
    INFO: Process project properties (done) | time=11ms
    INFO: Execute project builders
    INFO: Execute project builders (done) | time=2ms
    INFO: Project key: XX
    INFO: Base dir: /var/lib/jenkins/workspace/pipeline
    INFO: Working dir: /var/lib/jenkins/workspace/pipeline
    INFO: Load project settings for component key: ‘XX’
    INFO: Load project settings for component key: ‘XX’ (done) | time=430ms
    INFO: Load quality profiles
    INFO: Load quality profiles (done) | time=368ms
    INFO: Auto-configuring with CI ‘Jenkins’
    INFO: Load active rules
    INFO: Load active rules (done) | time=6168ms
    WARN: SCM provider autodetection failed. Please use “sonar.scm.provider” to define SCM of your project, or disable the SCM Sensor in the project settings.
    INFO: Indexing files…
    INFO: Project configuration:
    INFO: 1 file indexed
    INFO: ------------- Run sensors on module XXXXX
    INFO: Load metrics repository
    INFO: Load metrics repository (done) | time=355ms
    INFO: Sensor CSS Rules [cssfamily]
    INFO: No CSS, PHP, HTML or VueJS files are found in the project. CSS analysis is skipped.
    INFO: Sensor CSS Rules [cssfamily] (done) | time=2ms
    INFO: Sensor JaCoCo XML Report Importer [jacoco]
    INFO: ‘sonar.coverage.jacoco.xmlReportPaths’ is not defined. Using default locations: target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml,build/reports/jacoco/test/jacocoTestReport.xml
    INFO: No report imported, no coverage information will be imported by JaCoCo XML Report Importer
    INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=4ms
    INFO: Sensor C# Properties [csharp]
    INFO: Sensor C# Properties [csharp] (done) | time=2ms
    INFO: Sensor JavaXmlSensor [java]
    INFO: Sensor JavaXmlSensor [java] (done) | time=1ms
    INFO: Sensor HTML [web]
    INFO: Sensor HTML [web] (done) | time=3ms
    INFO: Sensor VB.NET Properties [vbnet]
    INFO: Sensor VB.NET Properties [vbnet] (done) | time=2ms
    INFO: ------------- Run sensors on project
    INFO: Sensor Zero Coverage Sensor
    INFO: Sensor Zero Coverage Sensor (done) | time=1ms
    INFO: SCM Publisher No SCM system was detected. You can use the ‘sonar.scm.provider’ property to explicitly specify it.
    INFO: CPD Executor Calculating CPD for 0 files
    INFO: CPD Executor CPD calculation finished (done) | time=0ms
    INFO: Analysis report generated in 160ms, dir size=82 KB
    INFO: Analysis report compressed in 25ms, zip size=10 KB
    INFO: Analysis report uploaded in 400ms
    INFO: ANALYSIS SUCCESSFUL, you can browse http://localhost:9000/dashboard?id=XX
    INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
    INFO: More about the report processing at http://localhost:9000/api/ce/task?id=AXj1aUnEnphUyL2uhmsM
    INFO: Analysis total time: 10.752 s
    INFO: ------------------------------------------------------------------------
    INFO: EXECUTION SUCCESS
    INFO: ------------------------------------------------------------------------
    INFO: Total time: 12.726s
    INFO: Final Memory: 6M/24M
    INFO: ------------------------------------------------------------------------
    [Pipeline] }
    WARN: Unable to locate ‘report-task.txt’ in the workspace. Did the SonarScanner succeed?
    [Pipeline] // withSonarQubeEnv
    [Pipeline] }
    [Pipeline] // stage
    [Pipeline] stage
    [Pipeline] { (Quality Gate)
    [Pipeline] timeout
    Timeout set to expire in 1 hr 0 min
    [Pipeline] {
    [Pipeline] waitForQualityGate
    [Pipeline] }
    [Pipeline] // timeout
    [Pipeline] }
    [Pipeline] // stage
    [Pipeline] }
    [Pipeline] // node
    [Pipeline] End of Pipeline
    java.lang.IllegalStateException: Unable to guess SonarQube task id and/or SQ server details. Please use the ‘withSonarQubeEnv’ wrapper to run your analysis.
    at