"Unable to locate 'report-task.txt' in the workspace", although it is there. Unable to utilize quality gate

Hello team,

I’m a little bit stuck, and would very much appreciate your feedback.

I’m running Jenkins latest, on Tomcat 8, on CentOS, no agents, to trigger a SonarQube analysis. The analysis is streamed in to SonarQube, successfully. At the end of the Jenkins console log though, the string “WARN: Unable to locate ‘report-task.txt’ in the workspace. Did the SonarScanner succedeed?” is printed. Why? The file is there:
-rw-r-----. 1 tomcat tomcat 296 Sep 19 09:13 report-task.txt

The file report-task.txt is located in the working dir, also documented as part of the Jenkins console log: “[INFO] Working dir: /mnt/fsdata/sonarqube”.

The issue is that I also want to utilize a quality gate, as part of my Jenkins job, and it fails, most probably because of not finding the report-task.txt, with the error: "
java.lang.IllegalStateException: Unable to get SonarQube task id and/or server name. Please use the ‘withSonarQubeEnv’ wrapper to run your analysis."

Here how I trigger my analysis (I fiddled around with the setup to test this behavior):

node {
    stage('SonarQube analysis') {
        withCredentials([string(credentialsId: 'SQ_TOKEN', variable: 'SQ_TOKEN')]) {
            withSonarQubeEnv('Sonar') {
   sh 'mvn clean compile -f /mnt/fsdata/tomcat/tmp/sandbox/all/pom.xml'
   sh 'mvn sonar:sonar -Dsonar.projectKey=com.huettermann:all -Dsonar.organization=michaelhuettermann-github -Dsonar.login=$SQ_TOKEN -Dsonar.host.url=https://sonarcloud.io -f /mnt/fsdata/tomcat/tmp/sandbox/all/pom.xml -Dsonar.java.binaries=/mnt/fsdata/tomcat/tmp/sandbox/all/target -Dsonar.junit.reportPaths=target/surefire-reports -Dsonar.jacoco.reportPaths=target/jacoco.exec -Dsonar.userHome=/mnt/fsdata/sonarqube -Dsonar.working.directory=/mnt/fsdata/sonarqube'

Thanks for your help.


help help :slight_smile:
I continued to play around with it, without success.

Hey Michael,

Just curious, and clarifying for now: what’s your use-case for forcefully specifying sonar.working.directory ? It’s pretty uncommon as far as I can tell, and makes me wonder if that could be related to your file not found in the workspace issue. Might be worth poking around with that property (e.g. behaviour if you do not set it ?)

Hi Nicolas.

Thanks for taking care. I’ve introduced the additional, optional parameters while trying to fix the issue. I get the exactly same result (message: “ WARN: Unable to locate ‘report-task.txt’ in the workspace. Did the SonarScanner succedeed? ”, and failing to utilize a quality gate) while just calling the minimal command:

mvn sonar:sonar -Dsonar.projectKey=com.huettermann:all -Dsonar.organization=michaelhuettermann-github -Dsonar.login=$SQ_TOKEN -Dsonar.host.url=https://sonarcloud.io -f /mnt/fsdata/tomcat/tmp/sandbox/all/pom.xml

What can I do to fix or nail down the issue?
Thank you.

Best regards

OK, replacing single units, narrowing, and trying couple of other things did not succeed, and I do not have any information how to drill down the issue. I understand that this is a core feature, and I know it to work very stable, I will re-install my entire system.


If you haven’t already wiped everything out and started over, I’d give it a try with the simplest possible analysis command. So instead of


sh ‘cd /mnt/fsdata/tomcat/tmp/sandbox/all’
sh ‘mvn sonar:sonar -Dsonar.projectKey=com.huettermann:all -Dsonar.organization=michaelhuettermann-github -Dsonar.login=$SQ_TOKEN -Dsonar.host.url=https://sonarcloud.io’

Most of what you made explicit should be picked up automatically from your project.


i have solve the problem,jenkins Prepare SonarQube Scanner environment must be true