Search code examples
azure-devopssonarqube

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


We run automated code-quality scans in SonarQube that are triggered by pipelines in Azure DevOps:

    # 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).

UPDATE 25/3/20 (thanks to patricklu-msft):

We are using a Microsoft-hosted build agent with an ubuntu-16.04 image. Running the pipeline in debug mode reveals the following:

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

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 ...


Solution

  • 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.

    Update 24/04/2020: I have now upgraded the Build Breaker plug-in to v2.3.1 (build 347) and that seems to have fixed the issue.