{"id":470,"date":"2013-05-13T15:30:52","date_gmt":"2013-05-13T14:30:52","guid":{"rendered":"http:\/\/qualilogy.com\/en\/?p=470"},"modified":"2013-09-01T15:44:41","modified_gmt":"2013-09-01T14:44:41","slug":"install-sonarqube-sonarqube-analysis-with-jenkins","status":"publish","type":"post","link":"http:\/\/qualilogy.com\/en\/install-sonarqube-sonarqube-analysis-with-jenkins\/","title":{"rendered":"Install SonarQube &#8211; SonarQube analysis with Jenkins"},"content":{"rendered":"<p><a href=\"http:\/\/vicken.deviantart.com\/\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" class=\"alignright size-full wp-image-821\" alt=\"Analyse Sonar avec Jenkins\" src=\"http:\/\/qualilogy.com\/fr\/wp-content\/uploads\/sites\/2\/2013\/05\/JenkinsAnalysis.jpg\" width=\"239\" height=\"360\" \/><\/a>This series of articles on installing SonarQube will end with this post. Let&#8217;s remember what were the objectives:<\/p>\n<ul>\n<li>Establish an environment of code analysis to measure the quality of applications.<\/li>\n<li>Without requiring technical knowledge about Java, databases, network, or open source tools.<\/li>\n<\/ul>\n<p>You are a pro in the Mainframe Cobol or SAP worlds, or a quality consultant, you act as as stakeholder or an interface between users and project teams, you are a project manager in charge of managing outsourcers for your IT department: this series showed you how to install SonarQube on your PC (a simple laptop in my case) in order to easily and regularly analyze any delivery of code or a new version of an application.<\/p>\n<p><!--more--><\/p>\n<p>And this last episode of this series will be about how to manage SonarQube analysis with Jenkins. For this, I will reuse the same Java code I previously <a href=\"http:\/\/qualilogy.com\/en\/install-sonar-first-analysis-with-sonar-runner\/\" target=\"_blank\">analyzed with the SonarQube Runner<\/a>.<\/p>\n<h2>Creating a SonarQube analysis with Jenkins<\/h2>\n<p><a href=\"http:\/\/qualilogy.com\/fr\/wp-content\/uploads\/sites\/2\/2013\/05\/JenkinsNuevaTarea.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignright size-full wp-image-833\" alt=\"Jenkins nouveau projet\" src=\"http:\/\/qualilogy.com\/fr\/wp-content\/uploads\/sites\/2\/2013\/05\/JenkinsNuevaTarea.jpg\" width=\"189\" height=\"125\" \/><\/a>First, we will create a project from the Jenkins menu located in the upper left corner of the main page.<\/p>\n<p>Select the menu &#8216;New Project&#8217; (Nueva Tarea&#8217; in my spanish interface): Jenkins displays the creation page of a project.<\/p>\n<p>It is possible to create different types of projects according to the equipment used (such as Maven). With SonarQube, we will choose the first option &#8216;Build a free-style software project&#8217; (&#8216;Crear a proyecto de estilo libre&#8217; in the screen below) and enter a project name: &#8216;Extranet&#8217; in our example. The &#8216;OK&#8217; button at the end of the page becomes active.<\/p>\n<p><a href=\"http:\/\/qualilogy.com\/fr\/wp-content\/uploads\/sites\/2\/2013\/05\/JenkinsProjectPage.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-835\" alt=\"Page de projet Jenkins\" src=\"http:\/\/qualilogy.com\/fr\/wp-content\/uploads\/sites\/2\/2013\/05\/JenkinsProjectPage.jpg\" width=\"601\" height=\"248\" \/><\/a><\/p>\n<p>Note that you will get an error message if you try to use a project name that already exists.<\/p>\n<p>Click the &#8216;OK&#8217; button to access the configuration page of the project.<\/p>\n<p><a href=\"http:\/\/qualilogy.com\/fr\/wp-content\/uploads\/sites\/2\/2013\/05\/JenkinsStandalone.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignright size-full wp-image-837\" alt=\"JenkinsStandalone\" src=\"http:\/\/qualilogy.com\/fr\/wp-content\/uploads\/sites\/2\/2013\/05\/JenkinsStandalone.jpg\" width=\"281\" height=\"166\" \/><\/a>I will not detail the many options available on this page, as I only use the one for log management, in order to automatically remove those beyond a certain date, or when they become too numerous.<\/p>\n<p>So we simply select the &#8216;Add New Task&#8217; button that opens the following list of menus in which we choose &#8216;Invoke Standalone Sonar Analysis&#8217;.<\/p>\n<p>This opens the configuration page for this project:<\/p>\n<p><a href=\"http:\/\/qualilogy.com\/fr\/wp-content\/uploads\/sites\/2\/2013\/05\/JenkinsProjectDetails.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-839\" alt=\"JenkinsProjectDetails\" src=\"http:\/\/qualilogy.com\/fr\/wp-content\/uploads\/sites\/2\/2013\/05\/JenkinsProjectDetails.jpg\" width=\"600\" height=\"244\" \/><\/a><\/p>\n<p>I just have to input into this page the localization of the &#8216;properties&#8217; file with all the parameters used for our <a href=\"http:\/\/qualilogy.com\/en\/install-sonar-first-analysis-with-sonar-runner\/\" target=\"_blank\">first analysis with the SonarQube Runner<\/a>: they were defined in a &#8216;sonar-project.properties&#8217; file located in a &#8216;..\\Projects&#8217; folder (under the &#8216;home&#8217; directory of the SonarQube Runner).<\/p>\n<p><span id=\"result_box\" lang=\"en\"><span class=\"hps\">And<\/span> <span class=\"hps\">in this post,<\/span> <span class=\"hps\">I told you<\/span> <span class=\"hps\">it was<\/span> <span class=\"hps\">important to manage<\/span> <span class=\"hps\">your environment<\/span> <span class=\"hps\">by clearly defining<\/span> <span class=\"hps\">where are located<\/span><span>,<\/span> <span class=\"hps\">for each application,<\/span> <span class=\"hps\">the source code and<\/span> <span class=\"hps\">everything<\/span> <span class=\"hps\">which contributes to the<\/span> <span class=\"hps\">configuration<\/span> of the <span class=\"hps\">analysis<\/span><span>.<\/span> <span class=\"hps\">I<\/span> <span class=\"hps\">use,<\/span> <span class=\"hps\">for each project<\/span><span>,<\/span> <span class=\"hps\">a directory<\/span> <span class=\"hps\">&#8216;Source&#8217;<\/span> <span class=\"hps\">with the corresponding<\/span> <span class=\"hps\">code,<\/span> <span class=\"hps\">and a folder<\/span> <span class=\"hps atn\">&#8216;<\/span><span>Implementation<\/span><span class=\"hps\">\\<\/span><span class=\"hps\">Conf<\/span><span>&#8216; in which<\/span> <span class=\"hps\">I&#8217;ll keep<\/span> <span class=\"hps\">the specific<\/span> (<span class=\"hps\">properties) file<\/span> with the same name than the analysis<span class=\"hps\">. <\/span><\/span><\/p>\n<p><span id=\"result_box\" lang=\"en\"><span class=\"hps\">This method has<\/span> <span class=\"hps\">many advantages<\/span><span>, including:<\/span><\/span><\/p>\n<ul>\n<li><span id=\"result_box\" lang=\"en\"><span class=\"hps\">You can<\/span> <span class=\"hps\">easily<\/span> <span class=\"hps\">find<\/span> <span class=\"hps\">the parameters of<\/span> any <span class=\"hps\">analysis, even<\/span> <span class=\"hps\">a long time after<\/span> you did <span class=\"hps\">it.<\/span><\/span><\/li>\n<li><span id=\"result_box\" lang=\"en\"><span class=\"hps\">You can<\/span> <span class=\"hps\">easily<\/span> <span class=\"hps\">duplicate the settings<\/span> <span class=\"hps\">of an analysis that<\/span> <span class=\"hps\">works perfectly with a copy of<\/span> <span class=\"hps\">the same properties file<\/span> <span class=\"hps\">for a new project<\/span><span>.<\/span> <span class=\"hps\">You still have<\/span><span class=\"hps\"> to<\/span> <span class=\"hps\">modify the values<\/span> <span class=\"hps\">\u200b\u200bfor these properties,<\/span> <span class=\"hps\">but I know<\/span> <span class=\"hps\">I would not<\/span> <span class=\"hps\">have forgotten<\/span> anything <span class=\"hps\">in<\/span> <span class=\"hps\">my settings<\/span><span>, so<\/span> <span class=\"hps\">that no error<\/span> <span class=\"hps\">will come from<\/span> <span class=\"hps\">it.<\/span><\/span><\/li>\n<li><span id=\"result_box\" lang=\"en\"><span class=\"hps\">If you work<\/span> <span class=\"hps\">together on<\/span> <span class=\"hps\">a shared server<\/span><span>,<\/span> <span class=\"hps\">following the same<\/span> <span class=\"hps\">configuration<\/span> <span class=\"hps\">(and<\/span> <span class=\"hps\">similar<\/span> <span class=\"hps\">practices)<\/span> <span class=\"hps\">will allow you to<\/span> <span class=\"hps\">go on<\/span> <span class=\"hps\">holiday<\/span> <span class=\"hps\">without any worry<\/span><span>: all other<\/span> <span class=\"hps\">members of your<\/span> <span class=\"hps\">team<\/span> <span class=\"hps\">will know exactly<\/span> <span class=\"hps\">how to<\/span> <span class=\"hps\">take<\/span> in charge <span class=\"hps\">your projects<\/span> <span class=\"hps\">without<\/span> <span class=\"hps\">having be part of them<\/span><span>.<\/span> <span class=\"hps\">This shall not preclude<\/span> <span class=\"hps\">a bit of<\/span> <span class=\"hps\">documentation<\/span> <span class=\"hps atn\">(<\/span><span>to<\/span> <span class=\"hps\">keep<\/span> <span class=\"hps atn\">in an &#8216;<\/span><span>Implementation<\/span>\\<span class=\"hps\">Docs<\/span><span class=\"hps\">\\&#8217; directory)<\/span> <span class=\"hps\">but<\/span> <span class=\"hps\">it will be<\/span> <span class=\"hps\">very brief<\/span><span>:<\/span> <span class=\"hps\">a single<\/span> <span class=\"hps\">sheet<\/span> <span class=\"hps\">description of the application<\/span> <span class=\"hps\">and<\/span> <span class=\"hps\">your analysis.<\/span><\/span><\/li>\n<\/ul>\n<p>So, I use exactly exactly the same parameters than the ones used for our <a href=\"http:\/\/qualilogy.com\/en\/install-sonar-first-analysis-with-sonar-runner\/\" target=\"_blank\">first analysis with the SonarQube Runner<\/a>.<\/p>\n<p><a href=\"http:\/\/qualilogy.com\/fr\/wp-content\/uploads\/sites\/2\/2013\/05\/JenkinsProjectProperties.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-840\" alt=\"JenkinsProjectProperties\" src=\"http:\/\/qualilogy.com\/fr\/wp-content\/uploads\/sites\/2\/2013\/05\/JenkinsProjectProperties.jpg\" width=\"484\" height=\"111\" \/><\/a><\/p>\n<p>Another advantage is that Jenkins, well the SonarQube plugin for Jenkins, allows me to override any value in this file from the &#8216;Invoke Standalone Sonar Analysis&#8217; configuration page and, as you can see in the previous figure, specify a new version number for this analysis or application:<\/p>\n<p style=\"padding-left: 30px;\"><strong>sonar.projectVersion=1.1<\/strong><\/p>\n<p><a href=\"http:\/\/qualilogy.com\/fr\/wp-content\/uploads\/sites\/2\/2013\/05\/JenkinsConstruir.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-full wp-image-842\" alt=\"JenkinsConstruir\" src=\"http:\/\/qualilogy.com\/fr\/wp-content\/uploads\/sites\/2\/2013\/05\/JenkinsConstruir.jpg\" width=\"144\" height=\"42\" \/><\/a>Don&#8217;t forget to save you settings before launching a new analysis.<\/p>\n<h2>Execution and log<\/h2>\n<p>A progress bar shows where you are in the analysis.<\/p>\n<p><a href=\"http:\/\/qualilogy.com\/fr\/wp-content\/uploads\/sites\/2\/2013\/05\/JenkinsExec.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-845\" alt=\"JenkinsExec\" src=\"http:\/\/qualilogy.com\/fr\/wp-content\/uploads\/sites\/2\/2013\/05\/JenkinsExec.jpg\" width=\"470\" height=\"151\" \/><\/a><\/p>\n<p>Then, a contextual menu allows you to see the log for this task, while it&#8217;s working or at the end of it.<\/p>\n<p><a href=\"http:\/\/qualilogy.com\/fr\/wp-content\/uploads\/sites\/2\/2013\/05\/JenkinsLog.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-846\" alt=\"JenkinsLog\" src=\"http:\/\/qualilogy.com\/fr\/wp-content\/uploads\/sites\/2\/2013\/05\/JenkinsLog.jpg\" width=\"1075\" height=\"194\" \/><\/a><\/p>\n<p><span id=\"result_box\" lang=\"en\"><span class=\"hps\">If you click on<\/span> <span class=\"hps\">the image above,<\/span> <span class=\"hps\">you can see<\/span> <span class=\"hps\">the various parameters<\/span> <span class=\"hps\">that<\/span> <span class=\"hps\">we actually<\/span> <span class=\"hps\">defined in our<\/span> <span class=\"hps\">Jenkins<\/span> <span class=\"hps\">configuration. <\/span><\/span><\/p>\n<p><span id=\"result_box\" lang=\"en\"><span class=\"hps\">In the same<\/span> <span class=\"hps\">log<\/span> <span class=\"hps\">page<\/span><span>,<\/span> <span class=\"hps\">you have a<\/span> <span class=\"hps\">menu<\/span> <span class=\"hps\">that allows you to<\/span> <span class=\"hps\">view<\/span> <span class=\"hps\">the<\/span> <span class=\"hps\">log<\/span> <span class=\"hps\">in text mode<\/span> <span class=\"hps\">in order to<\/span> <span class=\"hps\">save it as a file and\/or<\/span> <span class=\"hps\">send<\/span> it <span class=\"hps\">by email<\/span><span>, for example. <\/span><\/span><\/p>\n<p><span id=\"result_box\" lang=\"en\"><span class=\"hps\">And finally,<\/span> here is <span class=\"hps\">the result in<\/span> <span class=\"hps\">SonarQube<\/span><span>.<\/span><\/span><\/p>\n<p><a href=\"http:\/\/qualilogy.com\/fr\/wp-content\/uploads\/sites\/2\/2013\/05\/JenkinsSonarResult.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-848\" alt=\"JenkinsSonarResult\" src=\"http:\/\/qualilogy.com\/fr\/wp-content\/uploads\/sites\/2\/2013\/05\/JenkinsSonarResult.jpg\" width=\"419\" height=\"57\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p><span id=\"result_box\" lang=\"en\"><span class=\"hps\">We have seen<\/span> <span class=\"hps\">in this article<\/span> <span class=\"hps\">the main advantages<\/span> <span class=\"hps\">of using<\/span> <span class=\"hps\">Jenkins<\/span> <span class=\"hps\">with<\/span> <span class=\"hps\">SonarQube:<\/span><br \/>\n<\/span><\/p>\n<ul>\n<li><span id=\"result_box\" lang=\"en\"><span class=\"hps\">Organize our<\/span> <span class=\"hps\">analysis environment<\/span> <span class=\"hps\">as desired<\/span><span>, with a<\/span> <span class=\"hps\">specific configuration file<\/span> <span class=\"hps\">for each project<\/span><span>, that<\/span> <span class=\"hps\">we can<\/span> <span class=\"hps\">duplicate<\/span> <span class=\"hps\">at will. <\/span><\/span><\/li>\n<li><span id=\"result_box\" lang=\"en\">O<span class=\"hps\">verride a<\/span> <span class=\"hps\">parameter<\/span> <span class=\"hps\">&#8211;<\/span> <span class=\"hps\">as<\/span> <span class=\"hps\">the version number<\/span> <span class=\"hps\">&#8211;<\/span> <span class=\"hps\">for each analysis.<\/span><\/span><\/li>\n<li><span id=\"result_box\" lang=\"en\"><span class=\"hps\">Have a<\/span> <span class=\"hps\">much more user friendly<\/span> <span class=\"hps\">log<\/span> <span class=\"hps\">to consult<\/span><span>.<\/span><\/span><\/li>\n<\/ul>\n<p><span id=\"result_box\" lang=\"en\">Voil\u00e1, This is <span class=\"hps\">all it<\/span> <span class=\"hps\">is necessary to know<\/span> <span class=\"hps\">to<\/span> <span class=\"hps\">implement your own<\/span> <span class=\"hps\">analysis environment and<\/span> <span class=\"hps\">easily<\/span> <span class=\"hps\">measure<\/span> the quality of<span class=\"hps\"> applications<\/span> <span class=\"hps\">and<\/span> <span class=\"hps\">different technologies<\/span><span>,<\/span> <span class=\"hps\">without requiring any special<\/span> <span class=\"hps\">technical knowledge<\/span><span class=\"hps\">.<\/span><\/span><\/p>\n<p><span id=\"result_box\" lang=\"en\">About, different technos and languages, you may be interested by two other series on my blog, about the <span class=\"hps\">analysis<\/span> <span class=\"hps\">of\u00a0 <\/span><\/span><a href=\"http:\/\/qualilogy.com\/en\/category\/sonar\/sonar-cobol\/\" target=\"_blank\">Cobol<\/a> ou <a href=\"http:\/\/qualilogy.com\/en\/category\/sonar\/sonar-abap\/\" target=\"_blank\">SAP<\/a> applications with SonarQube.<\/p>\n<p>Up to you now. And do not hesitate to let a comment here if your analysis are successful.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This series of articles on installing SonarQube will end with this post. Let&#8217;s remember what were the objectives: Establish an environment of code analysis to measure the quality of applications. Without requiring technical knowledge about Java, databases, network, or open source tools. You are a pro in the Mainframe Cobol or SAP worlds, or a [&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-470","post","type-post","status-publish","format-standard","hentry","category-sonar-installation"],"_links":{"self":[{"href":"http:\/\/qualilogy.com\/en\/wp-json\/wp\/v2\/posts\/470"}],"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=470"}],"version-history":[{"count":13,"href":"http:\/\/qualilogy.com\/en\/wp-json\/wp\/v2\/posts\/470\/revisions"}],"predecessor-version":[{"id":472,"href":"http:\/\/qualilogy.com\/en\/wp-json\/wp\/v2\/posts\/470\/revisions\/472"}],"wp:attachment":[{"href":"http:\/\/qualilogy.com\/en\/wp-json\/wp\/v2\/media?parent=470"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/qualilogy.com\/en\/wp-json\/wp\/v2\/categories?post=470"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/qualilogy.com\/en\/wp-json\/wp\/v2\/tags?post=470"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}