{"id":658,"date":"2013-09-19T04:15:57","date_gmt":"2013-09-19T03:15:57","guid":{"rendered":"http:\/\/qualilogy.com\/en\/?p=658"},"modified":"2013-09-19T06:39:11","modified_gmt":"2013-09-19T05:39:11","slug":"sonarqube-windows-jenkins-tomcat","status":"publish","type":"post","link":"http:\/\/qualilogy.com\/en\/sonarqube-windows-jenkins-tomcat\/","title":{"rendered":"SonarQube as a Windows service with Jenkins under Tomcat"},"content":{"rendered":"<p><a href=\"http:\/\/vicken.deviantart.com\/\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" class=\"alignright size-full wp-image-1126\" alt=\"SonarQube2\" src=\"http:\/\/qualilogy.com\/fr\/wp-content\/uploads\/sites\/2\/2013\/09\/SonarQube2.jpg\" width=\"233\" height=\"350\" \/><\/a> We have seen in our previous post how to\u00a0<a href=\"http:\/\/qualilogy.com\/en\/migrate-sonarqube-tomcat-to-windows-service\/\" target=\"_blank\">migrate SonarQube <\/a>to a Windows service.<\/p>\n<p>We actually made \u200b\u200ba new installation, without loosing our repository previously built with our version of SonarQube under Tomcat. We have checked that our projects, the results of previous analyzes, but also all existing configurations (plugins, Quality Profiles, etc..) were not lost.<\/p>\n<p>Good. But what about Jenkins? Our Jenkins under Tomcat was working with the Tomcat version of SonarQube. And now it is working with SonarQube as a Windows service.<\/p>\n<p>How to proceed? Here are the steps I followed.<\/p>\n<p><!--more--><\/p>\n<p>&nbsp;<\/p>\n<h2>Uninstall SonarQube from Tomcat<\/h2>\n<p>The first step was to remove SonarQube from the Tomcat webapps. For this, I simply:<\/p>\n<ol>\n<li>Open the directory where it is located \u2013\u00a0<strong>C:\\Program Files (x86)\\Apache Software Foundation\\Tomcat 7.0\\webapps<\/strong>\u00a0\u2013\u00a0on my laptop.<\/li>\n<li>Delete the file &#8216;Sonar.war&#8217; and the sub-directory &#8216;Sonar&#8217; in this folder.<\/li>\n<\/ol>\n<p>Obviously, you have taken care to stop the Tomcat service before.<\/p>\n<h2>Launch an analysis with Jenkins under Tomcat<\/h2>\n<p>We will now attempt an analysis with Jenkins. This step is not mandatory, and I would say do not make sense: our current installation of Jenkins knows only the Tomcat version of SonarQube, that we have just delete.<\/p>\n<p>But as we have seen in our\u00a0<a href=\"http:\/\/qualilogy.com\/en\/migrate-sonarqube-tomcat-to-windows-service\/\" target=\"_blank\">previous post<\/a>,\u00a0SonarQube relies on its own repository, its own database\u00a0schema\u00a0 and our current Jenkins knows how to feed it.<\/p>\n<p>I will:<\/p>\n<p><a style=\"line-height: 1.714285714;font-size: 1rem\" href=\"http:\/\/qualilogy.com\/fr\/wp-content\/uploads\/sites\/2\/2013\/09\/StartTomcat.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignright size-full wp-image-1133\" alt=\"StartTomcat\" src=\"http:\/\/qualilogy.com\/fr\/wp-content\/uploads\/sites\/2\/2013\/09\/StartTomcat.jpg\" width=\"308\" height=\"67\" \/><\/a><\/p>\n<ul>\n<li>Start the Tomcat service Windows.<\/li>\n<li>Launch an existing analysis with Jenkins, taking care previously to change the project version for this analysis.<\/li>\n<\/ul>\n<p><a href=\"http:\/\/qualilogy.com\/fr\/wp-content\/uploads\/sites\/2\/2013\/09\/JenkinsSonarConf.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignright size-full wp-image-1136\" alt=\"JenkinsSonarConf\" src=\"http:\/\/qualilogy.com\/fr\/wp-content\/uploads\/sites\/2\/2013\/09\/JenkinsSonarConf.jpg\" width=\"300\" height=\"209\" \/><\/a>Click the drop-down menu that appears to the right of the link \/ project name, and in this menu, select\u00a0&#8216;Configure&#8217;.<\/p>\n<p>I chose here an application (actually different applications) with ABAP code (SAP) and. in the next window, the one to configure my analysis in Jenkins, I&#8217;ll change the project version to increment this version to 2.0.<\/p>\n<p>Do not forget to save the new setting before starting again this analysis.<\/p>\n<p><a href=\"http:\/\/qualilogy.com\/fr\/wp-content\/uploads\/sites\/2\/2013\/09\/SonarProjectPropVersion.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1137\" alt=\"SonarProjectPropVersion\" src=\"http:\/\/qualilogy.com\/fr\/wp-content\/uploads\/sites\/2\/2013\/09\/SonarProjectPropVersion.jpg\" width=\"580\" height=\"76\" \/><\/a><\/p>\n<p>Once finalized, we can see this new version 2.0 in the dashboard of SonarQube, as a service Windows&#8230;<\/p>\n<p><a href=\"http:\/\/qualilogy.com\/fr\/wp-content\/uploads\/sites\/2\/2013\/09\/SonarAbapV2.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1142\" alt=\"SonarAbapV2\" src=\"http:\/\/qualilogy.com\/fr\/wp-content\/uploads\/sites\/2\/2013\/09\/SonarAbapV2.jpg\" width=\"551\" height=\"51\" \/><\/a><\/p>\n<p>&#8230; even though Jenkins still knows only the Tomcat version of SonarQube:<\/p>\n<p><a href=\"http:\/\/qualilogy.com\/fr\/wp-content\/uploads\/sites\/2\/2013\/09\/SonarJenkinsV2.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1143\" alt=\"SonarJenkinsV2\" src=\"http:\/\/qualilogy.com\/fr\/wp-content\/uploads\/sites\/2\/2013\/09\/SonarJenkinsV2.jpg\" width=\"474\" height=\"72\" \/><\/a><\/p>\n<p>Once again, nothing wrong with that, since the results of the analysis are still stored in the repository of SonarQube, the &#8216;Sonar&#8217; schema in the database (Oracle in my case).<\/p>\n<h2>Configure Jenkins with the new SonarQube (Windows service)<\/h2>\n<p><a style=\"line-height: 1.714285714;font-size: 1rem\" href=\"http:\/\/qualilogy.com\/fr\/wp-content\/uploads\/sites\/2\/2013\/09\/JenkinsConfSystem.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignright size-full wp-image-1147\" alt=\"JenkinsConfSystem\" src=\"http:\/\/qualilogy.com\/fr\/wp-content\/uploads\/sites\/2\/2013\/09\/JenkinsConfSystem.jpg\" width=\"274\" height=\"49\" \/><\/a>In the window to manage Jenkins configuration\u00a0(&#8216;Manage Jenkins&#8217;), just activate the menu &#8216;Configure System&#8217;.<\/p>\n<p>In the following window, we will look for the SonarQube configuration in Jenkins, and select the &#8216;Advanced&#8230;&#8217; button.<\/p>\n<p><a href=\"http:\/\/qualilogy.com\/fr\/wp-content\/uploads\/sites\/2\/2013\/09\/JenkinsSonarConfig.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1149\" alt=\"JenkinsSonarConfig\" src=\"http:\/\/qualilogy.com\/fr\/wp-content\/uploads\/sites\/2\/2013\/09\/JenkinsSonarConfig.jpg\" width=\"550\" height=\"159\" \/><\/a>And in the next page of SonarQube configuration, we will modify the url of the SonarQube dashboard, which has changed with the\u00a0<a href=\"http:\/\/qualilogy.com\/en\/migrate-sonarqube-tomcat-to-windows-service\/\" target=\"_blank\">installation of SonarQube as a Windows\u00a0<\/a><a href=\"http:\/\/qualilogy.com\/en\/migrate-sonarqube-tomcat-to-windows-service\/\" target=\"_blank\">service<\/a>).<\/p>\n<p><a href=\"http:\/\/qualilogy.com\/fr\/wp-content\/uploads\/sites\/2\/2013\/09\/JenkinsSonarUrl.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1150\" alt=\"JenkinsSonarUrl\" src=\"http:\/\/qualilogy.com\/fr\/wp-content\/uploads\/sites\/2\/2013\/09\/JenkinsSonarUrl.jpg\" width=\"496\" height=\"108\" \/><\/a><\/p>\n<p><strong>Important note<\/strong>: You can see that I put the new url without the final slash. It will work, but I suggest you normalize this url by adding this slash.<\/p>\n<p>Do not forget to save this new parameter with the &#8216;Save&#8217; button at the bottom of the page.<\/p>\n<p>Jenkins use the SonarQube Runner to execute an analysis. We have seen how to install it in this post &#8216;<a style=\"line-height: 1.714285714;font-size: 1rem\" href=\"http:\/\/qualilogy.com\/en\/install-sonarqube-sonarqube-runner\/\" target=\"_blank\">Install SonarQube &#8211; SonarQube Runner<\/a>&#8216;.\u00a0On this occasion, we configured the SonarQube Runner with all the parameters necessary in the &#8216;sonar-runner.properties&#8217;.<\/p>\n<p>In this file, we will indicate the new url of the SonarQube portal, as previously mentioned under Jenkins.<\/p>\n<p><a href=\"http:\/\/qualilogy.com\/fr\/wp-content\/uploads\/sites\/2\/2013\/09\/SonarQubeSonarUrlOk.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1152\" alt=\"SonarQubeSonarUrlOk\" src=\"http:\/\/qualilogy.com\/fr\/wp-content\/uploads\/sites\/2\/2013\/09\/SonarQubeSonarUrlOk.jpg\" width=\"377\" height=\"60\" \/><\/a><\/p>\n<p>Note again the presence of the new slash at the end of url.<\/p>\n<p>Start the analysis. When finalized, the analysis log in Jenkins (or &#8216;Console Output&#8217;) should display the following message:<\/p>\n<pre><strong>ANALYSIS SUCCESSFUL, you can browse http:\/\/localhost:9000<\/strong><\/pre>\n<p>Note: at the beginning of this\u00a0log, you can see that the SonarQube &#8216;server&#8217; is indicated\u00a0with a slash at the end of the url, but this final message still appears without it.<\/p>\n<p>By clicking this link, you will access to SonarQube portal and see the results of your analysis. Do not forget to start the corresponding Windows service before.<\/p>\n<h2>Possible errors<\/h2>\n<p>I experimented with different combinations of SonarQube and Jenkins installations,\u00a0under Tomcat or as Windows services. I met some errors, and I will list two here, which I think might happen quite frequently. And you will understand why I insist on normalizing the slash at the end of the SonarQube url.<\/p>\n<p>If you get the following error message:<\/p>\n<pre><strong>The current batch process and the configured remote server do not share the same DB configuration.<\/strong>\r\n<strong> - Batch side: jdbc:oracle:thin:@localhost:1521\/JPORA11 (sonar \/ *****) <\/strong>\r\n<strong> - Server side: check the configuration at http:\/\/localhost:9000\/system<\/strong><\/pre>\n<p><span style=\"line-height: 1.714285714;font-size: 1rem\">Verify that you have specified exactly the same url in the configuration of SonarQube in Jenkins and in the &#8216;sonar-runner.properties&#8217; of the SonarQube Runner.<\/span><\/p>\n<p><span style=\"line-height: 1.714285714;font-size: 1rem\">If you get the following error message:<\/span><\/p>\n<pre><strong>Exception in thread \"main\" java.lang.IllegalStateException: Fail to request server version<\/strong>\r\n<strong> at org.sonar.runner.Bootstrapper.getServerVersion(Bootstrapper.java:73)<\/strong>\r\n<strong>...<\/strong>\r\n<strong>caused by: java.net.ConnectException: Connection refused: connect<\/strong>\r\n<strong> at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)<\/strong>\r\n<strong>...<\/strong>\r\n<strong> at java.net.URLConnection.getContent(URLConnection.java:748)<\/strong>\r\n<strong> at org.sonar.runner.Bootstrapper.remoteContent(Bootstrapper.java:125)<\/strong>\r\n<strong> at org.sonar.runner.Bootstrapper.getServerVersion(Bootstrapper.java:71)<\/strong>\r\n<strong> ... 4 more<\/strong>\r\n<strong>Finished: SUCCESS<\/strong><\/pre>\n<p>First begin to check that <strong>you have started the Windows service for SonarQube<\/strong>. I think this error will be the most common (at least in my experience).<\/p>\n<p>Recheck the urls and particularly the presence of the backslash at the end of it in the &#8216;sonar-runner.properties&#8217; configuration SonarQube Runner<span style=\"line-height: 1.714285714;font-size: 1rem\">.<\/span><\/p>\n<p><a href=\"http:\/\/qualilogy.com\/fr\/wp-content\/uploads\/sites\/2\/2013\/09\/SonarQubeSonarUrl.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1151\" alt=\"SonarQubeSonarUrl\" src=\"http:\/\/qualilogy.com\/fr\/wp-content\/uploads\/sites\/2\/2013\/09\/SonarQubeSonarUrl.jpg\" width=\"395\" height=\"122\" \/><\/a><\/p>\n<p>The SonarQube Runner does not work correctly if this url does not have this final slash. But anyway, if you followed the steps in this post and you got an error, first check the url in both Jenkins and SonarQube Runner. I also met this case and it may be difficult and long to investigate before thinking about adding this slash.<\/p>\n<p>The next post will be dedicated to the installation of Jenkins as a Windows service. And finally get rid of that good old Tomcat.<\/p>\n<p>See you soon.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We have seen in our previous post how to\u00a0migrate SonarQube to a Windows service. We actually made \u200b\u200ba new installation, without loosing our repository previously built with our version of SonarQube under Tomcat. We have checked that our projects, the results of previous analyzes, but also all existing configurations (plugins, Quality Profiles, etc..) were not [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-658","post","type-post","status-publish","format-standard","hentry","category-sonar-installation"],"_links":{"self":[{"href":"http:\/\/qualilogy.com\/en\/wp-json\/wp\/v2\/posts\/658"}],"collection":[{"href":"http:\/\/qualilogy.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/qualilogy.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/qualilogy.com\/en\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"http:\/\/qualilogy.com\/en\/wp-json\/wp\/v2\/comments?post=658"}],"version-history":[{"count":12,"href":"http:\/\/qualilogy.com\/en\/wp-json\/wp\/v2\/posts\/658\/revisions"}],"predecessor-version":[{"id":670,"href":"http:\/\/qualilogy.com\/en\/wp-json\/wp\/v2\/posts\/658\/revisions\/670"}],"wp:attachment":[{"href":"http:\/\/qualilogy.com\/en\/wp-json\/wp\/v2\/media?parent=658"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/qualilogy.com\/en\/wp-json\/wp\/v2\/categories?post=658"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/qualilogy.com\/en\/wp-json\/wp\/v2\/tags?post=658"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}