SonarQube/Azure DevOps code analysis failure - .scannerwork/report-task.txt not found

We run code-quality scans that are triggered by pipelines in Azure DevOps (defined in YAML):

    # retrieve and build code, run unit tests etc.
    - task: SonarQubePrepare@4
      displayName: 'Prepare SonarQube Scan'
      inputs:
        SonarQube: 'SonarQube DevOps Connection'
        scannerMode: 'CLI'
        configMode: 'file'
    - task: SonarQubeAnalyze@4
      displayName: 'Run SonarQube Scan'
    - task: SonarQubePublish@4
      displayName: 'Publish SonarQube Scan Report'
      inputs:
        pollingTimeoutSec: '300'

About a week ago, the main analysis task (‘Run SonarQube Scan’) began failing for all pipelines with the following error:

...
##[error]ERROR: Error during SonarQube Scanner execution
ERROR: Error during SonarQube Scanner execution
##[error]java.lang.IllegalStateException: Unable to load properties from file /home/vsts/work/1/s/.scannerwork/report-task.txt
java.lang.IllegalStateException: Unable to load properties from file /home/vsts/work/1/s/.scannerwork/report-task.txt
...
##[error]Caused by: java.io.FileNotFoundException: /home/vsts/work/1/s/.scannerwork/report-task.txt (No such file or directory)
Caused by: java.io.FileNotFoundException: /home/vsts/work/1/s/.scannerwork/report-task.txt (No such file or directory)
...

We have made no changes to our pipelines, so I am mystified as to what has caused this change.

We are using SonarQube Enterprise EditionVersion 7.9.1 (build 27448) (on-premise installation) and version 4.9.0 of the SonarQube extension for Azure DevOps (published by SonarSource). Our build agents in Azure use Ubuntu 16.04 images.

Hello,

Can you share the logs (begin + run analysis steps) with increased logging verbosity (just add /d:sonar.verbose=true to the begin step) relating to the this failing pipeline?

Greetings,
Kris

Thanks Kris. I have since run the pipeline with a general System.Debug=true variable set and generated the following logs:

2020-03-25T14:25:00.3679664Z 14:25:00.367 INFO: ANALYSIS SUCCESSFUL, you can browse https://domain/dashboard?id=project
...
2020-03-25T14:25:00.3694399Z 14:25:00.369 DEBUG: Report metadata written to /home/vsts/work/_temp/sonar/20200325.2/eec0f38a-913b-3db3-e1b2-71091ea5f860/report-task.txt
...
2020-03-25T14:25:00.5568445Z ##[error]java.lang.IllegalStateException: Unable to load properties from file /home/vsts/work/1/s/.scannerwork/report-task.txt
...
2020-03-25T14:25:00.5622558Z ##[error]Caused by: java.io.FileNotFoundException: /home/vsts/work/1/s/.scannerwork/report-task.txt (No such file or directory)

So it appears that the report metadata are being written to /home/vsts/work/_temp/sonar/20200325.2/eec0f38a-913b-3db3-e1b2-71091ea5f860/report-task.txt but SonarQube subsequently looks for them in /home/vsts/work/1/s/.scannerwork/report-task.txt . It looks like there is a mv operation missing somewhere …

I’ll run the pipeline again now with sonar.verbose=true and let you know what I find.

EDIT: I ran it with Sonar debugging enabled - the information was the same as with Azure debugging enabled. Let me know if there is anything specific you were expecting to find in the logs and I can post it here (I saved them - they are 48MB each, so I can’t post the whole thing!).

I worked it out in the end. Closer inspection of the Azure pipelines logs revealed these two entries that weren’t there before:

2020-03-26T15:26:44.0989881Z INFO: Executing post-job 'Forbidden Configuration Breaker'
2020-03-26T15:26:44.0990841Z INFO: Executing post-job 'Quality Gate Breaker'

Someone installed the Sonar Build-Breaker Plug-in a week ago without telling us, and none of us have correctly configured it in our pipelines yet. Setting it to skip the quality gate check ( sonar.buildbreaker.skip=true ) effectively by-passes it (although those two log entries still appear) and the pipelines run successfully once more.

Hi Ed,

Thanks for sharing - glad you solved it.
Greetings,
Kris

We had the same problem. Problem stopped happening after we upgrading Build Breaker in SonarQube to v 2.3.1 (build 347).

1 Like

Thanks Ian - that’s great news!

1 Like