{"id":80,"date":"2011-12-28T17:35:32","date_gmt":"2011-12-28T16:35:32","guid":{"rendered":"http:\/\/dev.qualilogy.com\/en\/?p=80"},"modified":"2013-01-04T17:37:09","modified_gmt":"2013-01-04T16:37:09","slug":"sonar-cobol-analysis-with-jenkins","status":"publish","type":"post","link":"http:\/\/qualilogy.com\/en\/sonar-cobol-analysis-with-jenkins\/","title":{"rendered":"Sonar &#8211; Cobol analysis with Jenkins"},"content":{"rendered":"<p>We saw in the <a title=\"Jenkins Installation\" href=\"http:\/\/qualilogy.com\/en\/sonar-jenkins-plugin?\" target=\"_blank\">previous post<\/a> how to install the Sonar plugin for Jenkins. It is now time to make our first analysis from Jenkins. It will focus on the Cobol source code already used in <a title=\"Sonar - 1st analysis\" href=\"http:\/\/qualilogy.com\/en\/sonar-first-analysis?lang=fr\" target=\"_blank\">our first analysis with Sonar and the Java Runner<\/a>. <!--more--><\/p>\n<p><a href=\"http:\/\/qualilogy.com\/wp-content\/uploads\/2011\/12\/SonarJenkinsAnalysis1.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignright size-full wp-image-578\" title=\"SonarJenkinsAnalysis1\" src=\"http:\/\/qualilogy.com\/wp-content\/uploads\/2011\/12\/SonarJenkinsAnalysis1.jpg\" alt=\"\" width=\"111\" height=\"29\" \/><\/a>For this, we will create a project from the main page of Jenkins.<\/p>\n<p>In the creation page, we enter a project name and select the first option: <a href=\"http:\/\/qualilogy.com\/wp-content\/uploads\/2011\/12\/SonarJenkinsAnalysis1_1.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignright size-full wp-image-579\" title=\"SonarJenkinsAnalysis1_1\" src=\"http:\/\/qualilogy.com\/wp-content\/uploads\/2011\/12\/SonarJenkinsAnalysis1_1.jpg\" alt=\"\" width=\"284\" height=\"72\" \/><\/a><\/p>\n<p>This opens the configuration page of this project, in which we say that we want a Sonar analysis:<a href=\"http:\/\/qualilogy.com\/wp-content\/uploads\/2011\/12\/SonarJenkinsAnalysis2a.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignright size-full wp-image-581\" title=\"SonarJenkinsAnalysis2a\" src=\"http:\/\/qualilogy.com\/wp-content\/uploads\/2011\/12\/SonarJenkinsAnalysis2a.jpg\" alt=\"\" width=\"285\" height=\"139\" \/><\/a><\/p>\n<p>Now, we just have to specify our configuration file, the same as the one used during our <a title=\"Sonar - Premi\u00e8re analyse\" href=\"http:\/\/qualilogy.com\/en\/sonar-first-analysis\" target=\"_blank\">first analysis wiht Sonar<\/a> : <strong>C:\\Soft\\Sonar\\sonar-runner-1.1\\Projects\\sonar-project.properties<\/strong>:<\/p>\n<p><a href=\"http:\/\/qualilogy.com\/wp-content\/uploads\/2011\/12\/SonarJenkinsAnalysis3.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-587\" title=\"SonarJenkinsAnalysis3\" src=\"http:\/\/qualilogy.com\/wp-content\/uploads\/2011\/12\/SonarJenkinsAnalysis3.jpg\" alt=\"\" width=\"569\" height=\"78\" \/><\/a>But first, we will enter a new version into this configuration file: <strong>sonar.projectVersion=1.1<\/strong>.<\/p>\n<p><a href=\"http:\/\/qualilogy.com\/wp-content\/uploads\/2011\/12\/SonarJenkinsAnalysis2b.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignright size-full wp-image-589\" title=\"SonarJenkinsAnalysis2b\" src=\"http:\/\/qualilogy.com\/wp-content\/uploads\/2011\/12\/SonarJenkinsAnalysis2b.jpg\" alt=\"\" width=\"68\" height=\"27\" \/><\/a>Don&#8217;t forget to save the parameters of this project.<\/p>\n<p>Before to start it.<a href=\"http:\/\/qualilogy.com\/wp-content\/uploads\/2011\/12\/SonarJenkinsAnalysis2c.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignright size-full wp-image-591\" title=\"SonarJenkinsAnalysis2c\" src=\"http:\/\/qualilogy.com\/wp-content\/uploads\/2011\/12\/SonarJenkinsAnalysis2c.jpg\" alt=\"\" width=\"121\" height=\"24\" \/><\/a><\/p>\n<p><a href=\"http:\/\/qualilogy.com\/wp-content\/uploads\/2011\/12\/SonarJenkinsAnalysis4a.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignright size-full wp-image-593\" title=\"SonarJenkinsAnalysis4a\" src=\"http:\/\/qualilogy.com\/wp-content\/uploads\/2011\/12\/SonarJenkinsAnalysis4a.jpg\" alt=\"\" width=\"270\" height=\"98\" \/><\/a>And while it is running&#8230;<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"http:\/\/qualilogy.com\/wp-content\/uploads\/2011\/12\/SonarJenkinsAnalysis4b.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignright size-full wp-image-595\" title=\"SonarJenkinsAnalysis4b\" src=\"http:\/\/qualilogy.com\/wp-content\/uploads\/2011\/12\/SonarJenkinsAnalysis4b.jpg\" alt=\"\" width=\"134\" height=\"19\" \/><\/a>We can have a look to the log:<\/p>\n<p><a href=\"http:\/\/qualilogy.com\/wp-content\/uploads\/2011\/12\/SonarJenkinsAnalysis41.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-597\" title=\"SonarJenkinsAnalysis4\" src=\"http:\/\/qualilogy.com\/wp-content\/uploads\/2011\/12\/SonarJenkinsAnalysis41.jpg\" alt=\"\" width=\"1041\" height=\"261\" \/><\/a>Then look at the result of the analysis into Sonar, with the version number indicated into our configuration file:<a href=\"http:\/\/qualilogy.com\/wp-content\/uploads\/2011\/12\/SonarJenkinsAnalysis5.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-598\" title=\"SonarJenkinsAnalysis5\" src=\"http:\/\/qualilogy.com\/wp-content\/uploads\/2011\/12\/SonarJenkinsAnalysis5.jpg\" alt=\"\" width=\"505\" height=\"49\" \/><\/a><\/p>\n<p>So we know how to avoid two inconveniences of the Java Runner (that we use due to our lack of practice of the Maven syntax):<\/p>\n<ol>\n<li>A unique configuration file: Jenkins allows us to specify a different file for every Sonar analysis.<\/li>\n<li>A much more practical and friendlier log every time we shall start one of our Sonar analyses.<\/li>\n<\/ol>\n<p>This allows us great flexibility, especially in the organization of our environment of analysis. Let&#8217;s see two examples.<\/p>\n<p>First, I will rename the sonar-project.properties as <strong>Myproject.properties<\/strong>, in the same directory ..<strong>\\sonar-runner-1.1\\Projects<\/strong>. I also modify the analyse release (<strong>sonar.projectVersion=1.2<\/strong>) in this file, in order to verify that this is this one that is taken in account.<\/p>\n<p>Then, I will configure the Jenkins project with this file, before to start it again&#8230;<a href=\"http:\/\/qualilogy.com\/wp-content\/uploads\/2011\/12\/SonarJenkinsAnalysis6.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-693\" title=\"SonarJenkinsAnalysis6\" src=\"http:\/\/qualilogy.com\/wp-content\/uploads\/2011\/12\/SonarJenkinsAnalysis6.jpg\" alt=\"\" width=\"559\" height=\"89\" \/><\/a><a href=\"http:\/\/qualilogy.com\/wp-content\/uploads\/2011\/12\/SonarJenkinsAnalysis7.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignright size-full wp-image-695\" title=\"SonarJenkinsAnalysis7\" src=\"http:\/\/qualilogy.com\/wp-content\/uploads\/2011\/12\/SonarJenkinsAnalysis7.jpg\" alt=\"\" width=\"297\" height=\"175\" \/><\/a>Let&#8217;s check the result in Sonar: we now have a new version 1.2. This means that I can use a space &#8216;Project&#8217; with as many configuration files that I have applications to analyze.<\/p>\n<p>&nbsp;<\/p>\n<p>Another kind of organization is to dedicate a hard drive to my analysis environment, with an application folder in which I would locate both the source code of the application, but also any configuration file. In this second example, I will:<\/p>\n<ul>\n<li>Create a directory <strong>G:\\Mainframe\\MyAppCobol<\/strong> for my application.<\/li>\n<li>In this folder, create a sub-directory <strong>\\Source<\/strong> where I will copy the Cobol programs to analyze.<\/li>\n<li>In this folder, create a sub-directory <strong>\\Implementation\\Conf<\/strong> where I will put the Sonar configuration file <strong>MyAppCobol.properties<\/strong><\/li>\n<li>In this file, modify the property <strong>sources=G:\/Mainframe\/MyAppCobol\/Source<\/strong> in order to specify the new localisation for the Cobol souce code.<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-full wp-image-699\" title=\"SonarJenkinsAnalysis8\" src=\"http:\/\/qualilogy.com\/wp-content\/uploads\/2011\/12\/SonarJenkinsAnalysis81.jpg\" alt=\"\" width=\"341\" height=\"196\" \/>Here is what my new environment looks like.<\/p>\n<p>Finally, we modify the configuration of our Jenkins project to take into account the new Sonar configuration file, and run a new analysis.<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-700\" title=\"SonarJenkinsAnalysis9\" src=\"http:\/\/qualilogy.com\/wp-content\/uploads\/2011\/12\/SonarJenkinsAnalysis9.jpg\" alt=\"\" width=\"614\" height=\"87\" \/><\/p>\n<p>So we can see that it is possible to organize analysis as we want, either by centralizing all configuration files within a single folder \\Projects (for example) or by decentralizing each one at the level of the application.<\/p>\n<p>We can handle as many analysis as we want, of any technology supported by a Sonar plugin, and use the Jenkins console to manage lofgs of analysis.<\/p>\n<p>Finally, the implemented solution is based on the Java Runner Sonar without requiring any particular knowledge of other tools such as Ant or Maven.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We saw in the previous post how to install the Sonar plugin for Jenkins. It is now time to make our first analysis from Jenkins. It will focus on the Cobol source code already used in our first analysis with Sonar and the Java Runner.<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,7],"tags":[],"class_list":["post-80","post","type-post","status-publish","format-standard","hentry","category-sonar-cobol","category-sonar-installation"],"_links":{"self":[{"href":"http:\/\/qualilogy.com\/en\/wp-json\/wp\/v2\/posts\/80"}],"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=80"}],"version-history":[{"count":1,"href":"http:\/\/qualilogy.com\/en\/wp-json\/wp\/v2\/posts\/80\/revisions"}],"predecessor-version":[{"id":81,"href":"http:\/\/qualilogy.com\/en\/wp-json\/wp\/v2\/posts\/80\/revisions\/81"}],"wp:attachment":[{"href":"http:\/\/qualilogy.com\/en\/wp-json\/wp\/v2\/media?parent=80"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/qualilogy.com\/en\/wp-json\/wp\/v2\/categories?post=80"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/qualilogy.com\/en\/wp-json\/wp\/v2\/tags?post=80"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}