Our docker builds that use SonarQube (specifically through the dotnet-sonarscanner global tool) started hanging indefinitely after our base image cache expired and the latest version (8.0.0) started being picked up.
The problem happens when running the end command in a Docker container where the source code is at the root (.sln file at /, .csproj files under their respective folders). There is no error logged by the tool, it just seems to get stuck. We waited an hour in one case before cancelling the build.
Running again with verbose logs (/d:sonar.verbose=true) yields:
#21 [build 11/11] RUN dotnet sonarscanner end /d:sonar.token=***
#21 0.540 SonarScanner for MSBuild 8.0
#21 0.540 Using the .NET Core version of the Scanner for MSBuild
#21 0.614 Post-processing started.
#21 0.704 12:38:08.802 12:38:08.796 Uninstalling target: /.sonarqube/bin/targets/SonarQube.Integration.targets
#21 0.704 12:38:08.802 12:38:08.802 sonar.verbose=true was specified - setting the log verbosity to 'Debug'
#21 0.705 12:38:08.803 Loading the SonarQube analysis config from /.sonarqube/conf/SonarQubeAnalysisConfig.xml
#21 0.705 12:38:08.803 Not running under TeamBuild
#21 0.706 12:38:08.804 Analysis base directory: /.sonarqube
#21 0.706 Build directory:
#21 0.706 Bin directory: /.sonarqube/bin
#21 0.706 Config directory: /.sonarqube/conf
#21 0.706 Output directory: /.sonarqube/out
#21 0.706 Config file: /.sonarqube/conf/SonarQubeAnalysisConfig.xml
#21 0.707 12:38:08.805 12:38:08.805 WARNING: Multi-Language analysis is enabled. If this was not intended, please set "/d:sonar.scanner.scanAll=false" in the begin step.
#21 0.790 12:38:08.888 Generating SonarQube project properties file to /.sonarqube/out/sonar-project.properties
#21 0.813 12:38:08.911 Setting analysis property: sonar.visualstudio.enable=false
#21 0.826 12:38:08.923 The supplied Code Analysis ErrorLog file is a valid json file and does not need to be fixed: /.sonarqube/out/1/Issues.json
#21 0.839 12:38:08.937 The supplied Code Analysis ErrorLog file is a valid json file and does not need to be fixed: /.sonarqube/out/0/Issues.json
#21 0.849 12:38:08.947 Using working directory as project base directory: '/'.
To be 100% clear, nothing else is logged after the last line above, we have to manually cancel the build.
As the files are already at the root, setting /d:sonar.projectBaseDir=/ does not work (it just complains that all files are outside the scan directory). Is there anything we can do besides sticking to the previous version?
The logs provided in the initial thread are the verbose logs for the END task.
The MS Build logs contain a lot of proprietary information that I cannot share publicly. I’m happy to look for anything in particular you need or send through a private channel.
To be clear, this was working perfectly fine with version 7.1.1.
As a workaround until the new version is released, you can set the /d:sonar.projectBaseDir= parameter in the scanner begin step. This will disable the automatic detection and will fix the hang.
Interesting, what is the value set for the sonar.projectBaseDir? It should point to the folder where your project sources are and not the .sonarqube directory.
I tried with passing both projectBaseDir=/ and projectBaseDir=./ to the begin command. I got similar, if not the same, results. The last 3 lines of errors in both cases were:
#21 1.084 12:24:13.067 No analysable projects were found. SonarQube analysis will not be performed. Check the build summary report for details.
#21 1.084 12:24:13.067 Generation of the sonar-properties file failed. Unable to complete the analysis.
#21 1.087 12:24:13.07 Post-processing failed. Exit code: 1
Are all the source files in the projectBaseDir or in one of it’s nested folders?
Do you run the project build from the same folder from where you run the scanner begin step?
What operating system do you use? Is / pointing to the root of the file system (Unix) or current folder? If you’re not sure you can also provide the full path.
Martin just released a new version of the scanner but I’m not sure if your issue will be solved. You can give it a try.
If your project sources are really at the root of the file system, the scanner will try to analyze all the files and nested directories, starting with the root. This takes a long time and most probably it’s not what you want. You can disable this functionality by setting /d:sonar.scanner.scanAll=false in the begin step.
Having the verbose logs for both the begin and end step would help us to better understand the problem. You can sanitize them and remove all the sensitive information. And if you want I can DM you so we can have a private channel.
The error message makes me think that project base dir is set to one of the nested folders and not to the parent directory that contains all the source code. Could you try to set the projectBaseDir to an absolute path?