Must-share information (formatted with Markdown):
-
which versions are you using (SonarQube: 10.1.0.73491, Scanner: Sonar-scanner-4.8.0.2856 , Plugin: N/A, and any relevant extension)
-
how is SonarQube deployed: zip
-
what are you trying to achieve: To run a scan on my dotnet project using a different machine than the one that the server is hosted on. I’ve gotten sonarscanner to start and the app builds fine. The only errors pop up when I run the “end” command for sonarscanner. The scanner is trying to access the wrong url (http://127.0.0.1:9000/sonarqube) for some reason and I can’t find out why.
-
what have you tried so far to achieve this: I’ve edited the SonarQube.Analysis.xml folder to contain the right sonar.host.url (172.xx.xx.xx:9000/sonarqube) i can confirm this works becuase I am able to connect to it on a different machine. And I’ve also edited the sonar-scanner.properties file to have the same host url.
I’m running the code with a jenkins pipeline. Here are the logs:
C:\Jenkins\workspace\master_ws\software\Applications\projectName>“C:\Jenkins\tools\hudson.plugins.sonar.MsBuildSQRunnerInstallation\SonarScanner_for_MSBuild\SonarScanner.MSBuild.exe” end
SonarScanner for MSBuild 5.13
Using the .NET Framework version of the Scanner for MSBuild
Post-processing started.
15:45:39.658 15:45:39.658 WARNING: File ‘C:\Jenkins\workspace\master_ws\log4netTemplate\Template\AppHost\Release\Log4Net.template’ is not located under the base directory ‘C:\Jenkins\workspace\master_ws\software’ and will not be analyzed.
Calling the TFS Processor executable…
The TFS Processor has finished
Calling the SonarScanner CLI…
INFO: Scanner configuration file: C:\Jenkins\tools\hudson.plugins.sonar.MsBuildSQRunnerInstallation\SonarScanner_for_MSBuild\sonar-scanner-4.8.0.2856\bin..\conf\sonar-scanner.properties
INFO: Project root configuration file: C:\Jenkins\workspace\master_ws\software\Applications\VirtekIrisClient.sonarqube\out\sonar-project.properties
INFO: SonarScanner 4.8.0.2856
INFO: Java 11.0.18 Oracle Corporation (64-bit)
INFO: Windows 10 10.0 amd64
INFO: User cache: C:\Users\build.sonar\cache
ERROR: SonarQube server [http://127.0.0.1:9000/sonarqube] can not be reached
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 0.490s
INFO: Final Memory: 4M/17M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarScanner execution
This is my sonar-scanner.properties file:
#Configure here general information about the environment, such as SonarQube server connection details for example
#No information about specific project should appear here
#----- Default SonarQube server
sonar.host.url=http://172.xx.xx.xx:9000/sonarqube
#----- Default source code encoding
#sonar.sourceEncoding=UTF-8
this is my SonarQube.Analysis.xml file:
<?xml version="1.0" encoding="utf-8" ?>
<SonarQubeAnalysisProperties xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.sonarsource.com/msbuild/integration/2015/1">
<Property Name="sonar.host.url">http://172.xx.xx.xx:9000/sonarqube</Property>
<Property Name="sonar.login">sqxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</Property>
</SonarQubeAnalysisProperties>
This is my jenkins script:
stage('SonarQube Analysis'){
def msbuildHome = tool 'VS 2022'
def scannerHome = tool 'SonarScanner for MSBuild'
echo "Starting SonarQube Analysis"
withSonarQubeEnv(){
bat "\"${scannerHome}\\SonarScanner.MSBuild.exe\" begin /k:\"projectName\" /s:\"C:\Jenkins\workspace\master_ws\software\Applications\projectName\SonarQube.Analysis.xml""
bat "\"${tool 'VS 2022'}\\msbuild.exe\" ${_Internal_Solution_Name}.sln -p:Configuration=Release -p:Platform=\"${_Common_Internal_Paramter_Platform}\" ${_Internal_Nuget_Version_Prefix} -target:Rebuild ${_Define_Constant}"
bat "\"${scannerHome}\\SonarScanner.MSBuild.exe\" end"
}
}