I am using Jenkins job to build .Net project. I have added sonar analysis.
D:\Temp\tools\Scanner_MSBuild-2.2\MSBuild.SonarQube.Runner.exe begin /k:myproj /n:myproj-full /v:1.0.0 /s:D:\Temp\SonarQube.Analysis.xml
I have updated "SonarQube.Analysis.xml" with required sonar url and login credentials. But it fails with following error:
Pre-processing started.
Preparing working directories...
SonarQube Scanner for MSBuild 2.2
09:07:00.437 Updating build integration targets...
09:07:00.451 Fetching analysis configuration settings...
09:07:01.239 Could not find a file on the SonarQube server. URL: https:///api/qualityprofiles/search?defaults=true
09:07:01.239 Pre-processing failed. Exit code: 1
I tried following:
D:\Temp\tools\Scanner_MSBuild-2.2\MSBuild.SonarQube.Runner.exe begin /k:myproj /n:myproj-full /v:1.0.0 /s:D:\Temp\SonarQube.Analysis.xml -Dsonar.buildbreaker.skip=true
But it threw error that -Dsonar.buildbreaker.skip=true is not recognised command. By default buildbreaker is set to false and I am not able to make it true via commandline. SonarQube version I am using is below 5.2.
How do I fix this?
Thank you
If you're using the 'Begin Analysis' and 'End Analysis' build steps, then configuring your server URL in SonarQube.Analysis.xml won't get you far (as you've learned).
Instead, you need to configure the location of your server at the global level as described in the docs. Briefly:
Manage Jenkins > Configure System > SonarQube configuration
Add SonarQube
fill in your server info.
Then double check that that server instance is selected in your build steps (if you have only one server configured, build steps will default to it). And analyze.
Related
I have a TFS 2013 build that I'm trying to get to publish to a folder on the build server. I've installed WebDeploy, but I always get the error:
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\Web\Microsoft.Web.Publishing.targets (4274): Web deployment task failed. (Could not connect to the remote computer ("localhost"). On the remote computer, make sure that Web Deploy is installed and that the required process ("Web Management Service") is started. Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_DESTINATION_NOT_REACHABLE.)
I've set up a website on the build server and that's where I'm trying to publish the website. Actually I don't even care about publishing it per se - I just need my build output to go to a folder locally automatically. Right now we have to manually open the solution and choose Publish... to get the output that subsequent InstallShield builds need for input. Here are my MSBuild arguments. Does anyone have any idea what could be missing?
/p:SrcDir=C:\Builds\TFS\WebApps\Src
/p:RevKeyname=WebAppsRevNr
/p:DeployOnBuild=true
/p:DeployTarget=MsDeployPublish
/p:MSDeployServiceURL=https://127.0.0.1:8172/msdeploy.axd
/p:CreatePackageOnPublish=True
/p:DeployIisAppPath="WebApp"
/p:MsDeployPublishMethod=WMSVC
/p:AllowUntrustedCertificate=True
/p:AutoParameterizationWebConfigConnectionStrings=False
/p:Authtype=NTLM /p:username=""
I've checked both net start wmsvc and net start msdepsvc and both are running. Any ideas?
Thanks!
UPDATE
I've tried everything that Andy suggested and now when I run this from the command line I get this bizarre error message:
"C:\Workspace\VS2013\WebApps\Main\Src\webapps.sln" (default target) (1) ->
"C:\Workspace\VS2013\WebApps\Main\Src\CoreWebApps\CoreWebApps.csproj"
(default
target) (7) ->
(AutoParameterizationWebConfigConnectionStringsCore target) ->
C:\Program Files
(x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.Web
.Publishing.targets(2295,5): error : Could not open Source file: Could not
find
a part of the path
'C:\Workspace\VS2013\WebApps\Main\Src\CoreWebApps\Areas\Adm
in\Views\Web.config;Areas\Admin\Views\Web.config'.
[C:\Workspace\VS2013\WebApps
\Main\Src\CoreWebApps\CoreWebApps.csproj]
Any idea why it's looking for Web.config;Areas\Admin\Views\Web.config'.? That makes no sense.
Please try below items to narrow down the issue:
Try to use IP or Machine Name instead of "localhost"
Logon your build agent machine, then manually execute the same
MSBuild command within the same arguments(which you provided in build
definition) to build and deploy your solution, then check result. You
need to ensure you can manually run the same MSBuild command within
deploy argument to build and deploy your solution successfully from
build agent machine. Then use the same deploy arguments in TFS Build
definition.
Double check Web Deploy settings to make sure that the name of the
website is exactly that of what's in IIS.
Install Web Management Tools before Web
Deploy : Install the Web Management Services (Roles -> Web Server >
Management Tools > Management Services). Then uninstall Web Deploy, and then install Web Deploy again.
You can also reference this thread for your troubleshooting.
Update:
For the issue "Could not open Source file: Could not find a part of the path" you can reference below similar articles for the troubleshooting.
https://social.msdn.microsoft.com/Forums/en-US/8f959964-c951-4f9a-8486-8283a925c9f6/build-error-could-not-open-source-file-though-i-know-it-exists?forum=windowsazurewebsitespreview
https://our.umbraco.org/forum/getting-started/installing-umbraco/60222-Umbraco-721-Build-fails-after-deploy-to-Azure-WebSite (See the last two answers)
I'm having issues trying to execute the SonarQube Scanner. The begin part seems to run without issues, and also the MSBuild command, but the end part fails.
1st step: I execute the following SonarQube Scanner command:
D:\workspace\MasterData>SonarQube.Scanner.MSBuild.exe begin /k:"masterdata" /n:"MasterData" /v:"1.0" /d:sonar.host.url=http: //xyz.com.br:9000/sonarqube /d:sonar.login=5773c2ca935fde42c72494a96de5a68a5b6899d1 /d:sonar.verbose=true
SonarQube Scanner for MSBuild 2.2
Default properties file was found at D:\sonar-scanner-msbuild-2.2.0.24\SonarQube.Analysis.xml
Loading analysis properties from D:\sonar-scanner-msbuild-2.2.0.24\SonarQube.Analysis.xml
sonar.verbose=true was specified - setting the log verbosity to 'Debug'
Pre-processing started.
Preparing working directories...
Using environment variables to determine the download directory...
Removing the existing directory: D:\workspace\MasterData\.sonarqube
Creating directory: D:\workspace\MasterData\.sonarqube
SonarQube server URL: http: //xyz.com.br:9000/sonarqube
SonarQube Scanner for MSBuild 2.2
15:11:10.032 Loading analysis properties from D:\sonar-scanner-msbuild-2.2
.0.24\SonarQube.Analysis.xml
15:11:10.04 sonar.verbose=true was specified - setting the log verbosity to 'Debug'
15:11:10.042 Updating build integration targets...
15:11:10.045 Installed SonarQube.Integration.ImportBefore.targets to C:\Users\AppData\Local\Microsoft\MSBuild\14.0\Microsoft.Common.targets\ImportBefore
15:11:10.046 Installed SonarQube.Integration.ImportBefore.targets to C:\Users\f
g009adm\AppData\Local\Microsoft\MSBuild\12.0\Microsoft.Common.targets\ImportBefore
15:11:10.048 Installed SonarQube.Integration.targets to D:\workspace\MasterData\.sonarqube\bin\targets
15:11:10.049 Creating config and output folders...
15:11:10.049 Creating directory: D:\workspace\MasterData\.sonarqube\conf
15:11:10.049 Creating directory: D:\workspace\MasterData\.sonarqube\out
15:11:10.055 Fetching analysis configuration settings...
15:11:10.062 Fetching properties for project 'masterdata' from http: //xyz.com.br:9000/sonarqube/api/properties?resource=masterdata...
15:11:10.062 Downloading from http: //xyz.com.br:9000/sonarqube/api/properties?resource=masterdata...
15:11:10.214 Downloading from http: //xyz.com.br:9000/sonarqube/api/updatecenter/installed_plugins...
15:11:10.239 Fetching quality profile for project 'masterdata' from http: //xyz.com.br:9000/sonarqube/api/qualityprofiles/search?projectKey=masterdata...
15:11:10.24 Downloading from http: //xyz.com.br:9000/sonarqube/api/qu
alityprofiles/search?projectKey=masterdata...
15:11:10.272 Downloading from http: //xyz.com.br:9000/sonarqube/api/rules/search?f=repo,name,severity,lang,internalKey,templateKey,params,actives&ps=
500&activation=true&qprofile=cs-sbs-cs-default-201410-86215&p=1...
15:11:10.451 Downloading from http: //xyz.com.br:9000/sonarqube/api/rules/search?f=internalKey&ps=500&activation=false&qprofile=cs-sbs-cs-default-201410-86215&p=1&languages=cs...
15:11:10.506 Generating rulesets...
15:11:10.506 Generating the FxCop ruleset: D:\workspace\MasterData\.sonarq
ube\conf\SonarQubeFxCop-cs.ruleset
15:11:10.518 Writing Roslyn generated ruleset to D:\workspace\MasterData\.sonarqube\conf\SonarQubeRoslyn-cs.ruleset...
15:11:10.534 Writing Roslyn analyzer additional file to D:\workspace\MasterData\.sonarqube\conf\cs\SonarLint.xml...
15:11:10.536 Provisioning analyzer assemblies for cs...
15:11:10.538 Installing required Roslyn analyzers...
15:11:10.538 Local analyzer cache: C:\Users\fg009adm\AppData\Local\Temp\7\.sonarqube\.static
15:11:10.538 Processing plugin: csharp version 1.23.0.1828
15:11:10.54 Cache hit: using plugin files from C:\Users\AppData\Local\Temp\7\.sonarqube\.static\csharp_1.23.0.1828\SonarAnalyzer-1.23.0.1828.zip
15:11:10.566 Pre-processing succeeded.
2nd step: I execute the following MSBuild command:
MSBuild.exe /t:Rebuild MasterDataWebServices.sln
Since the MSBuild log is quite big, I will not provide it here. There is a Build succeeded message, with 5 warnings and 0 errors.
3rd step: I execute the following SonarQube Scanner end command:
D:\workspace\MasterData>SonarQube.Scanner.MSBuild.exe end
SonarQube Scanner for MSBuild 2.2
Default properties file was found at D:\sonar-scanner-msbuild-2.2.0.24\SonarQube.Analysis.xml
Loading analysis properties from D:\sbs1\sonar-scanner-msbuild-2.2.0.24\SonarQube.Analysis.xml
Post-processing started.
SonarQube Scanner for MSBuild 2.2
14:25:22.961 Loading the SonarQube analysis config from D:\workspace\MasterData\.sonarqube\conf\SonarQubeAnalysisConfig.xml
14:25:22.964 Not running under TeamBuild
14:25:22.964 Analysis base directory: D:\workspace\MasterData\.sonarqube
Build directory:
Bin directory: D:\workspace\MasterData\.sonarqube\bin
Config directory: D:\workspace\MasterData\.sonarqube\conf
Output directory: D:\workspace\MasterData\.sonarqube\out
Config file: D:\workspace\MasterData\.sonarqube\conf\SonarQubeAnalysisConfig.xml
Generating SonarQube project properties file to D:\workspace\MasterData\.sonarqube\out\sonar-project.properties
The SonarQube MSBuild integration failed: SonarQube was unable to collect the required information about your projects.
Possible causes:
1. The project has not been built - the project must be built in between the begin and end steps
2. An unsupported version of MSBuild has been used to build the project. Currently MSBuild 12.0 upwards are supported
3. The begin, build or end steps have not all been launched from the same folder
Writing processing summary to D:\workspace\MasterData\.sonarqube\out\ProjectInfo.log
Generation of the sonar-properties file failed. Unable to complete SonarQube ana
lysis.
14:25:22.988 Creating a summary markdown file...
14:25:22.989 Post-processing failed. Exit code: 1
I was facing the same problem. In my case I installed corresponding MSBuild version required by my version of Sonar and it worked just fine.
My SonarScanner required version 14.0 or upwards of MSBuild, then I downloaded Microsoft Build Tools 2015.
In your case I believe it this version will work too and if not you can try this version more specifically.
Hope it helps.
I'm facig some issues with SonarQube integration in TeamCity with MSBuild.
Basically our nightly build using SonarQube is split into 5 steps:
1 - SonarQube Initialization
MSBuild.SonarQube.Runner.exe begin
/k:"tsmm-%sonar.project%"
/n:"%sonar.project%"
/v:"%sonar.project.version%"
/d:sonar.host.url="%sonar.host.url%"
/d:sonar.cs.dotcover.reportsPaths="coverage-report.html"
/d:sonar.cs.nunit.reportsPaths="nunit-results.xml"
/d:sonar.verbose=true
/d:sonar.jdbc.username="%sonar.jdbc.username%"
/d:sonar.jdbc.password="%sonar.jdbc.password%"
/d:sonar.jdbc.url="%sonar.jdbc.url%"
2 - Muggets restauration
3 - MSBuild
4 - Tests via NUnit
5 - Result publication to SonarQube
MSBuild.SonarQube.Runner.exe end
/d:sonar.scm.disabled=true
/d:sonar.jdbc.username="%sonar.jdbc.username%"
/d:sonar.jdbc.password="%sonar.jdbc.password%"
When the TeamCity is running the build definition above, everything is going fine until it reach the step no. 5 as stated in the build log:
Step 5/5: Publish to SonarQube (Command Line)
ERROR: Error during Sonar runner execution
org.sonar.runner.impl.RunnerException: Unable to execute Sonar
at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:91)
...
Caused by: org.sonar.api.utils.SonarException: SCM URL should be provided. Please review "sonar.scm.url" parameter (or the <scm> section of pom.xml if you are using Maven).
I went through different resources including the official one there: http://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner+for+MSBuild
But could not manage to find out any proper explanation, I also tried to disable the scm support as mentioned on that page: http://docs.sonarqube.org/display/SONAR/SCM+support
by adding /d:sonar.scm.disabled=true to the step 1 but it does not change anything.
The sonar.jdbc.* properties are only for older versions of SonarQube and if you are on a newer than 5.4, you should not set them.
To authenticate to SonarQube you need to use the sonar.login and sonar.password properties, as described in the article below:
http://docs.sonarqube.org/display/SCAN/From+the+Command+Line#FromtheCommandLine-Analyzeaproject
In all cases, if you have older SonarQube, I would strongly recommend upgrading to the LTS (long term support) version:
https://www.sonarqube.org/downloads/
I'm trying out SonarQube using the new MSBuild SonarQube Runner v1.0. If I install a fresh SonarQube server locally, the following command works fine, and I can build my solution directly afterward, call the 'end' command, and have the results published in SonarQube:
MSBuild.SonarQube.Runner.exe begin /key:TestKey /name:TestName /version:1.0.0.0
However, if I run this against an existing SonarQube server that exists on the internal network, it always returns with exit code 1:
15:32:40 Creating config and output folders...
15:32:40 Creating directory: c:\Test\MSBuild.SonarQube.Runner-1.0.itsonar\.sonarqube\conf
15:32:40 Creating directory: c:\Test\MSBuild.SonarQube.Runner-1.0.itsonar\.sonarqube\out
15:32:41 Generating the FxCop ruleset: c:\Test\MSBuild.SonarQube.Runner-1.0.itsonar\.sonarqube\conf\SonarQubeFxCop-cs.ruleset
Process returned exit code 1
It seems to download a lot of the dependencies into /.sonarqube, so communication with the server isn't an issue
Things I've tried:
checked the access.log, server.log and event logs
upgraded the existing server to v5.1.2 (clean install using the guide)
upgraded the sonar-csharp-plugin to v4.1
right-clicked all .jar files on the server and ensured they are unblocked
tried the runner directly on the server
(ongoing) tried debugging the source code (happening somewhere in the pre-process step: success comes back as true, but the error code is 1)
disabled UAC on the server an rebooted
re-installed JRE on both server and client, ensure JAVA_HOME in both PATH and registry are set correctly
Any help or pointers greatly accepted. I've been stuck on this for 2 days and can't think of anything else to try except continue trawling through source code. Thank you.
This is a tricky one! Looking at the code, I see only one path that can yield this output:
It fails while generating the FxCop ruleset for C#, as the VB.NET FxCop ruleset message is not logged - see TeamBuildPreProcessor.cs#L149 and TeamBuildPreProcessor.cs#L185
The GenerateFxCopRuleset() call for C# threw a WebException, leading to the call of Utilities.HandleHostUrlWebException() - which has to return true for the exception to be silently swallowed - see Utilities.cs#L153
The only path returning true without logging any message is if a HttpStatusCode.NotFound was received - see Utilities.cs#L158
The control flow goes back to FetchArgumentsAndRulesets(), which returns false, then goes back to Execute() which returns false as well - see TeamBuildPreProcessor.cs#L106
The MSBuild SonarQube Runner "begin" phase (called "preprocessor" in the code) fails - see Program.cs#L42
So, at some point, some SonarQube web service required for the C# FxCop ruleset generation is return a HTTP 404 error.
Could you monitor your network traffic and listen for the failing HTTP call? [I will keep on updating this answer afterwards]
EDIT: Indeed the error is caused by the quality profile name containing special characters. Such characters are currently badly URL-escaped, which leads to a 404.
I've created the following ticket to fix this issue in the upcoming release: http://jira.sonarsource.com/browse/SONARMSBRU-125
I am using Jenkins and Ant to run my selenium tests. It works fine when I run them on my local machine.
Now I have a Jenkins server which is on a different location and I have to run my tests on that server.
when I tried to run the tests on that server Its is failing because it couldn't find the build.xml file. can you please let me know how can I change the home directory path?
Started by user :**********
Building in workspace /var/lib/jenkins/jobs/moveon4 java tests/workspace
FATAL: Unable to find build script at C:\selenium tests for move\movetests1\build.xml
Build step 'Invoke Ant' marked build as failure
Finished: FAILURE
Are you using "Invoke Ant" in your Jenkins job configuration for the build step that executes your Ant build ? If so, the build file location is hidden away in the Advanced section - it's an annoying quirk of Jenkins.