<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>sonarqube Archives - Tech Chronicles</title>
	<atom:link href="http://kostacipo.stream/tag/sonarqube/feed/" rel="self" type="application/rss+xml" />
	<link>https://kostacipo.stream/tag/sonarqube/</link>
	<description>Ramblings of a Tech Dude</description>
	<lastBuildDate>Mon, 13 Apr 2020 12:05:34 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.2</generator>

<image>
	<url>https://kostacipo.stream/wp-content/uploads/2019/12/cropped-profile-32x32.jpg</url>
	<title>sonarqube Archives - Tech Chronicles</title>
	<link>https://kostacipo.stream/tag/sonarqube/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>SonarQube Integration with Jenkins Using Pipelines</title>
		<link>http://kostacipo.stream/sonarqube-integration-with-jenkins-using-pipelines/</link>
					<comments>http://kostacipo.stream/sonarqube-integration-with-jenkins-using-pipelines/#respond</comments>
		
		<dc:creator><![CDATA[Majordomo]]></dc:creator>
		<pubDate>Mon, 13 Apr 2020 12:05:34 +0000</pubDate>
				<category><![CDATA[DevOps]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[jenkins]]></category>
		<category><![CDATA[sonarqube]]></category>
		<guid isPermaLink="false">http://www.kostacipo.stream/?p=1779</guid>

					<description><![CDATA[<p>SonarQube Integration is an open source static code analysis tool that is gaining tremendous popularity among software developers. It enables software professionals to measure code quality, identify non-compliant code, and fix code quality issues. The SonarQube community is quite active and provides continuous upgrades, new plug-ins, and customization information on a regular basis. Further, it [&#8230;]</p>
<p>The post <a href="http://kostacipo.stream/sonarqube-integration-with-jenkins-using-pipelines/">SonarQube Integration with Jenkins Using Pipelines</a> appeared first on <a href="http://kostacipo.stream">Tech Chronicles</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p style="text-align: justify;">SonarQube Integration is an open source static code analysis tool that is gaining tremendous popularity among software developers. It enables software professionals to measure code quality, identify non-compliant code, and fix code quality issues. The SonarQube community is quite active and provides continuous upgrades, new plug-ins, and customization information on a regular basis. Further, it is a healthy practice to periodically run SonarQube on the source code to fix code quality violations and reduce the technical debt.</p>
<p style="text-align: justify;">SonarQube enables developers to track code quality, which helps them to ascertain if a project is ready to be deployed in production. Further, it allows developers to continuously inspect the code, perform automatic reviews and run analysis to find code quality issues.</p>
<p style="text-align: justify;">Furthermore, SonarQube provides a lot of other features, including the ability to record metrics, evolution graphs etc. It has inherent options to perform automated analysis and <a href="https://en.wikipedia.org/wiki/Continuous_integration" target="_blank" rel="noopener noreferrer">continuous integration</a> utilizing tools such as <a href="https://jenkins-ci.org/" target="_blank" rel="noopener noreferrer">Jenkins</a>, <a href="http://hudson-ci.org/" target="_blank" rel="noopener noreferrer">Hudson</a>, etc. In this blog, we will explore the process of creating pipeline scripts for SonarQube integration. Here are the steps.</p>
<ul style="text-align: justify;">
<li>Log in to your configuration domain (e.g. https://jenkins.domain.com).</li>
<li>Go to the specific profile in Jenkins (Here, in this case, it is the root project).</li>
<li>To configure a Sonar job, select <em>‘New Item’</em> available on the left side panel in Jenkins.</li>
</ul>
<p style="text-align: justify;"><img decoding="async" class="aligncenter size-full wp-image-3490 lazyloaded" src="https://i2.wp.com/d331tpl5vusgqa.cloudfront.net/wp-content/uploads/2017/12/New-Item.png?resize=154%2C168&amp;ssl=1" alt="New Item" data-recalc-dims="1" data-lazy-src="https://i2.wp.com/d331tpl5vusgqa.cloudfront.net/wp-content/uploads/2017/12/New-Item.png?resize=154%2C168&amp;ssl=1" data-was-processed="true" width="154" height="168"></p>
<ul style="text-align: justify;">
<li>In the subsequent screen provide a job name. Click on <em>‘Pipeline’</em> option, if you intend to run a Pipeline, else select the <em>‘Maven’</em> option.</li>
</ul>
<p style="text-align: justify;"><img fetchpriority="high" decoding="async" class="aligncenter size-full wp-image-3492 lazyloaded" src="https://i0.wp.com/d331tpl5vusgqa.cloudfront.net/wp-content/uploads/2017/12/Pipeline-Maven.png?resize=380%2C370&amp;ssl=1" sizes="(max-width: 380px) 100vw, 380px" srcset="https://i0.wp.com/www.evoketechnologies.com/wp-content/uploads/2017/12/Pipeline-Maven.png?w=380&amp;ssl=1 380w, https://i0.wp.com/www.evoketechnologies.com/wp-content/uploads/2017/12/Pipeline-Maven.png?resize=300%2C292&amp;ssl=1 300w" alt="Pipeline Maven" data-lazy-srcset="https://i0.wp.com/www.evoketechnologies.com/wp-content/uploads/2017/12/Pipeline-Maven.png?w=380&amp;ssl=1 380w, https://i0.wp.com/www.evoketechnologies.com/wp-content/uploads/2017/12/Pipeline-Maven.png?resize=300%2C292&amp;ssl=1 300w" data-lazy-sizes="(max-width: 380px) 100vw, 380px" data-recalc-dims="1" data-lazy-src="https://i0.wp.com/d331tpl5vusgqa.cloudfront.net/wp-content/uploads/2017/12/Pipeline-Maven.png?resize=380%2C370&amp;ssl=1" data-was-processed="true" width="380" height="370"></p>
<ul style="text-align: justify;">
<li>Click on <em>‘OK’</em> button to provide configuration details. Now, let us take a look at the various links available on the left side of the screen.
<ul>
<li>Changes – The <em>‘Changes’</em> option enables developers to change the name of a job.</li>
<li>Build Now – This feature allows developers to run a job in Jenkins. It starts to read the code from the&nbsp;repository and builds the code.</li>
<li>Configure – This option enables developers to read the code from the Git/SVN repository.</li>
</ul>
</li>
</ul>
<p style="text-align: justify;"><img decoding="async" class="aligncenter size-full wp-image-3493 lazyloaded" src="https://i1.wp.com/d331tpl5vusgqa.cloudfront.net/wp-content/uploads/2017/12/Pipeline-inc-web.png?resize=622%2C283&amp;ssl=1" sizes="(max-width: 622px) 100vw, 622px" srcset="https://i1.wp.com/www.evoketechnologies.com/wp-content/uploads/2017/12/Pipeline-inc-web.png?w=622&amp;ssl=1 622w, https://i1.wp.com/www.evoketechnologies.com/wp-content/uploads/2017/12/Pipeline-inc-web.png?resize=300%2C136&amp;ssl=1 300w" alt="Pipeline inc-web" data-lazy-srcset="https://i1.wp.com/www.evoketechnologies.com/wp-content/uploads/2017/12/Pipeline-inc-web.png?w=622&amp;ssl=1 622w, https://i1.wp.com/www.evoketechnologies.com/wp-content/uploads/2017/12/Pipeline-inc-web.png?resize=300%2C136&amp;ssl=1 300w" data-lazy-sizes="(max-width: 622px) 100vw, 622px" data-recalc-dims="1" data-lazy-src="https://i1.wp.com/d331tpl5vusgqa.cloudfront.net/wp-content/uploads/2017/12/Pipeline-inc-web.png?resize=622%2C283&amp;ssl=1" data-was-processed="true" width="622" height="283"></p>
<h3 style="text-align: justify;">SonarQube Integration with Jenkins</h3>
<p style="text-align: justify;">Here is the complete process of&nbsp;SonarQube integration with Jenkins.</p>
<ul style="text-align: justify;">
<li>Click on <em>‘Configure’</em> option, which will redirect developers to the following screen, enabling them to read the code from the Git/SVN repository.</li>
<li>In the General tab, developers can provide a Pipeline name and log build details, such as how many days the logs should be kept etc. In the <em>‘Days to keep builds’</em> field, enter the&nbsp;number of days.</li>
</ul>
<p style="text-align: justify;"><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-3494 lazyloaded" src="https://i0.wp.com/d331tpl5vusgqa.cloudfront.net/wp-content/uploads/2017/12/General.png?resize=638%2C388&amp;ssl=1" sizes="auto, (max-width: 638px) 100vw, 638px" srcset="https://i0.wp.com/www.evoketechnologies.com/wp-content/uploads/2017/12/General.png?w=638&amp;ssl=1 638w, https://i0.wp.com/www.evoketechnologies.com/wp-content/uploads/2017/12/General.png?resize=300%2C182&amp;ssl=1 300w" alt="General" data-lazy-srcset="https://i0.wp.com/www.evoketechnologies.com/wp-content/uploads/2017/12/General.png?w=638&amp;ssl=1 638w, https://i0.wp.com/www.evoketechnologies.com/wp-content/uploads/2017/12/General.png?resize=300%2C182&amp;ssl=1 300w" data-lazy-sizes="(max-width: 638px) 100vw, 638px" data-recalc-dims="1" data-lazy-src="https://i0.wp.com/d331tpl5vusgqa.cloudfront.net/wp-content/uploads/2017/12/General.png?resize=638%2C388&amp;ssl=1" data-was-processed="true" width="638" height="388"></p>
<ul style="text-align: justify;">
<li>If using a Git repository, select Git project, else proceed to the next tab.</li>
<li>The next tab is ‘<em>Office 365 Connector</em>’, this screen is used to run a build based on parameters.</li>
<li>The option <em>‘This project is parameterized’</em> is one of the parameters that developers should have a brief idea. It is used to build a job based on branches. In situations, where developers want to run a job based on development/master branches, they can define it using this option else, the job will run as default.</li>
</ul>
<p style="text-align: justify;"><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-3521 lazyloaded" src="https://i0.wp.com/d331tpl5vusgqa.cloudfront.net/wp-content/uploads/2017/12/Office-365-Connector-1.png?resize=637%2C297&amp;ssl=1" sizes="auto, (max-width: 637px) 100vw, 637px" srcset="https://i1.wp.com/www.evoketechnologies.com/wp-content/uploads/2017/12/Office-365-Connector-1.png?w=637&amp;ssl=1 637w, https://i1.wp.com/www.evoketechnologies.com/wp-content/uploads/2017/12/Office-365-Connector-1.png?resize=300%2C140&amp;ssl=1 300w" alt="Office 365 Connector" data-lazy-srcset="https://i1.wp.com/www.evoketechnologies.com/wp-content/uploads/2017/12/Office-365-Connector-1.png?w=637&amp;ssl=1 637w, https://i1.wp.com/www.evoketechnologies.com/wp-content/uploads/2017/12/Office-365-Connector-1.png?resize=300%2C140&amp;ssl=1 300w" data-lazy-sizes="(max-width: 637px) 100vw, 637px" data-recalc-dims="1" data-lazy-src="https://i0.wp.com/d331tpl5vusgqa.cloudfront.net/wp-content/uploads/2017/12/Office-365-Connector-1.png?resize=637%2C297&amp;ssl=1" data-was-processed="true" width="637" height="297"></p>
<ul style="text-align: justify;">
<li><strong>Build Trigger Section</strong> – This option can be utilized, if developers are keen to run the jobs based on specific time intervals e.g. once a day or twice a day. Additionally, jobs can be scheduled to run automatically by using the <em>‘Build periodically’</em> option.</li>
<li><strong>Pipeline Section</strong> – The pipeline section is the core feature of a job; it reads data/code from a specific repository in GIT/SVN. However, developers need to specify the script file, which is available in the GIT/SVN application.</li>
</ul>
<p style="text-align: justify;"><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-3522 lazyloaded" src="https://i0.wp.com/d331tpl5vusgqa.cloudfront.net/wp-content/uploads/2017/12/Pipeline-1.png?resize=625%2C346&amp;ssl=1" sizes="auto, (max-width: 625px) 100vw, 625px" srcset="https://i1.wp.com/www.evoketechnologies.com/wp-content/uploads/2017/12/Pipeline-1.png?w=625&amp;ssl=1 625w, https://i1.wp.com/www.evoketechnologies.com/wp-content/uploads/2017/12/Pipeline-1.png?resize=300%2C166&amp;ssl=1 300w" alt="Pipeline" data-lazy-srcset="https://i1.wp.com/www.evoketechnologies.com/wp-content/uploads/2017/12/Pipeline-1.png?w=625&amp;ssl=1 625w, https://i1.wp.com/www.evoketechnologies.com/wp-content/uploads/2017/12/Pipeline-1.png?resize=300%2C166&amp;ssl=1 300w" data-lazy-sizes="(max-width: 625px) 100vw, 625px" data-recalc-dims="1" data-lazy-src="https://i0.wp.com/d331tpl5vusgqa.cloudfront.net/wp-content/uploads/2017/12/Pipeline-1.png?resize=625%2C346&amp;ssl=1" data-was-processed="true" width="625" height="346"></p>
<ul style="text-align: justify;">
<li>Here is the pipeline script that needs to be added to the Jenkins file.</li>
</ul>
<div style="text-align: justify;">
<div id="highlighter_603459" class="syntaxhighlighter  java">
<div class="toolbar"><a class="toolbar_item command_help help" href="https://www.evoketechnologies.com/blog/sonarqube-integration-jenkins-pipelines/#">?</a></div>
<table cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr>
<td class="gutter">
<div class="line number1 index0 alt2">1</div>
<div class="line number2 index1 alt1">2</div>
<div class="line number3 index2 alt2">3</div>
<div class="line number4 index3 alt1">4</div>
<div class="line number5 index4 alt2">5</div>
<div class="line number6 index5 alt1">6</div>
<div class="line number7 index6 alt2">7</div>
<div class="line number8 index7 alt1">8</div>
</td>
<td class="code">
<div class="container">
<div class="line number1 index0 alt2"><code class="java keyword">try</code> <code class="java plain">{</code></div>
<div class="line number2 index1 alt1"><code class="java plain">stage(</code><code class="java string">"Building SONAR ..."</code><code class="java plain">) {</code></div>
<div class="line number3 index2 alt2"><code class="java plain">sh </code><code class="java string">'./gradlew clean sonarqube'</code></div>
<div class="line number4 index3 alt1"><code class="java plain">}</code></div>
<div class="line number5 index4 alt2"><code class="java plain">} </code><code class="java keyword">catch</code> <code class="java plain">(e) {emailext attachLog: </code><code class="java keyword">true</code><code class="java plain">, body: </code><code class="java string">'See attached log'</code><code class="java plain">, subject: </code><code class="java string">'BUSINESS Build Failure'</code><code class="java plain">, to: </code><code class="java string">'abc@gmail.com'</code></div>
<div class="line number6 index5 alt1"><code class="java plain">step([$</code><code class="java keyword">class</code><code class="java plain">: </code><code class="java string">'WsCleanup'</code><code class="java plain">])</code></div>
<div class="line number7 index6 alt2"><code class="java keyword">return</code></div>
<div class="line number8 index7 alt1"><code class="java plain">}</code></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<ul style="text-align: justify;">
<li>Add the following plugin details in the build.gradle/pom.xml file (if it is maven):</li>
</ul>
<p style="text-align: justify;">a) Sonar Plugin</p>
<div style="text-align: justify;">
<div id="highlighter_651812" class="syntaxhighlighter  java">
<table cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr>
<td class="gutter">
<div class="line number1 index0 alt2">1</div>
<div class="line number2 index1 alt1">2</div>
<div class="line number3 index2 alt2">3</div>
</td>
<td class="code">
<div class="container">
<div class="line number1 index0 alt2"><code class="java plain">dependencies {</code></div>
<div class="line number2 index1 alt1"><code class="java plain">classpath </code><code class="java string">"org.sonarsource.scanner.gradle: sonarqube-gradle-plugin:2.5"</code></div>
<div class="line number3 index2 alt2"><code class="java plain">}</code></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p style="text-align: justify;">b) Apply plugin: ‘org.sonarqube’</p>
<p style="text-align: justify;">c) Add SonarQube Server Details:</p>
<div style="text-align: justify;">
<div id="highlighter_478216" class="syntaxhighlighter  java">
<table cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr>
<td class="gutter">
<div class="line number1 index0 alt2">1</div>
<div class="line number2 index1 alt1">2</div>
<div class="line number3 index2 alt2">3</div>
<div class="line number4 index3 alt1">4</div>
<div class="line number5 index4 alt2">5</div>
<div class="line number6 index5 alt1">6</div>
<div class="line number7 index6 alt2">7</div>
</td>
<td class="code">
<div class="container">
<div class="line number1 index0 alt2"><code class="java plain">sonarqube {</code></div>
<div class="line number2 index1 alt1"><code class="java plain">properties {</code></div>
<div class="line number3 index2 alt2"><code class="java plain">property </code><code class="java string">"sonar.host.url"</code><code class="java plain">, http:</code><code class="java comments">//sonar.xxxxx.com //&nbsp; url is your sonar server</code></div>
<div class="line number4 index3 alt1"><code class="java plain">property </code><code class="java string">"sonar.projectName"</code><code class="java plain">, </code><code class="java string">"project&nbsp; display name"</code>&nbsp;&nbsp; <code class="java comments">//&nbsp; this name will appear in dashboard</code></div>
<div class="line number5 index4 alt2"><code class="java plain">property </code><code class="java string">"sonar.projectKey"</code><code class="java plain">, </code><code class="java string">"projectKey"</code> <code class="java comments">// It sould be a keybased on this report is created</code></div>
<div class="line number6 index5 alt1"><code class="java plain">property </code><code class="java string">"sonar.groovy.jacoco.reportPath"</code><code class="java plain">, </code><code class="java string">"${project.buildDir}/jacoco/test.exec"</code>&nbsp;&nbsp;&nbsp; <code class="java plain">}</code></div>
<div class="line number7 index6 alt2"><code class="java plain">}</code></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<ul style="text-align: justify;">
<li>Once the configuration is complete, developers can build job manually or automatically. This can be activated using the option ‘<em>Build Now</em>’ available on left side panel of the screen.</li>
</ul>
<p style="text-align: justify;"><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-3498 lazyloaded" src="https://i2.wp.com/d331tpl5vusgqa.cloudfront.net/wp-content/uploads/2017/12/Build-Job.png?resize=204%2C229&amp;ssl=1" alt="Build Job" data-recalc-dims="1" data-lazy-src="https://i2.wp.com/d331tpl5vusgqa.cloudfront.net/wp-content/uploads/2017/12/Build-Job.png?resize=204%2C229&amp;ssl=1" data-was-processed="true" width="204" height="229"></p>
<ul style="text-align: justify;">
<li>After the build process is complete in Jenkins, it reads the code and compares each line, if it observes any violations of rules, it sends a report to the sonar server. Here is a sample snapshot of the SonarQube report.</li>
</ul>
<p style="text-align: justify;"><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-3499 lazyloaded" src="https://i0.wp.com/d331tpl5vusgqa.cloudfront.net/wp-content/uploads/2017/12/Java-Maven-Project.png?resize=641%2C448&amp;ssl=1" sizes="auto, (max-width: 641px) 100vw, 641px" srcset="https://i0.wp.com/www.evoketechnologies.com/wp-content/uploads/2017/12/Java-Maven-Project.png?w=641&amp;ssl=1 641w, https://i0.wp.com/www.evoketechnologies.com/wp-content/uploads/2017/12/Java-Maven-Project.png?resize=300%2C210&amp;ssl=1 300w" alt="Java Maven Project" data-lazy-srcset="https://i0.wp.com/www.evoketechnologies.com/wp-content/uploads/2017/12/Java-Maven-Project.png?w=641&amp;ssl=1 641w, https://i0.wp.com/www.evoketechnologies.com/wp-content/uploads/2017/12/Java-Maven-Project.png?resize=300%2C210&amp;ssl=1 300w" data-lazy-sizes="(max-width: 641px) 100vw, 641px" data-recalc-dims="1" data-lazy-src="https://i0.wp.com/d331tpl5vusgqa.cloudfront.net/wp-content/uploads/2017/12/Java-Maven-Project.png?resize=641%2C448&amp;ssl=1" data-was-processed="true" width="641" height="448"></p>
<p style="text-align: justify;">Developers can view a list of issues on the SonarQube dashboard. If they are interested to find out what went wrong in their code base, all they have to do it simply click on specific links (numbers above). This action will redirect developers to specific code, where they can fix the issues.</p>
<p style="text-align: justify;">Here is an example, below is a test class, where we have created a sample Java class.</p>
<p style="text-align: justify;"><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-3500 lazyloaded" src="https://i1.wp.com/d331tpl5vusgqa.cloudfront.net/wp-content/uploads/2017/12/Sample-Java-Class.png?resize=633%2C452&amp;ssl=1" sizes="auto, (max-width: 633px) 100vw, 633px" srcset="https://i1.wp.com/www.evoketechnologies.com/wp-content/uploads/2017/12/Sample-Java-Class.png?w=633&amp;ssl=1 633w, https://i1.wp.com/www.evoketechnologies.com/wp-content/uploads/2017/12/Sample-Java-Class.png?resize=300%2C214&amp;ssl=1 300w" alt="Sample Java Class" data-lazy-srcset="https://i1.wp.com/www.evoketechnologies.com/wp-content/uploads/2017/12/Sample-Java-Class.png?w=633&amp;ssl=1 633w, https://i1.wp.com/www.evoketechnologies.com/wp-content/uploads/2017/12/Sample-Java-Class.png?resize=300%2C214&amp;ssl=1 300w" data-lazy-sizes="(max-width: 633px) 100vw, 633px" data-recalc-dims="1" data-lazy-src="https://i1.wp.com/d331tpl5vusgqa.cloudfront.net/wp-content/uploads/2017/12/Sample-Java-Class.png?resize=633%2C452&amp;ssl=1" data-was-processed="true" width="633" height="452"></p>
<p style="text-align: justify;">If you observe, Code Smells count is 3, clicking on number 3 will redirect developers to the following screen on a Sonar server. Further, it will show/suggest the vulnerability based on the rule.</p>
<p style="text-align: justify;"><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-3501 lazyloaded" src="https://i1.wp.com/d331tpl5vusgqa.cloudfront.net/wp-content/uploads/2017/12/Code-smells-count.png?resize=639%2C199&amp;ssl=1" sizes="auto, (max-width: 639px) 100vw, 639px" srcset="https://i2.wp.com/www.evoketechnologies.com/wp-content/uploads/2017/12/Code-smells-count.png?w=639&amp;ssl=1 639w, https://i2.wp.com/www.evoketechnologies.com/wp-content/uploads/2017/12/Code-smells-count.png?resize=300%2C93&amp;ssl=1 300w" alt="Code smells count" data-lazy-srcset="https://i2.wp.com/www.evoketechnologies.com/wp-content/uploads/2017/12/Code-smells-count.png?w=639&amp;ssl=1 639w, https://i2.wp.com/www.evoketechnologies.com/wp-content/uploads/2017/12/Code-smells-count.png?resize=300%2C93&amp;ssl=1 300w" data-lazy-sizes="(max-width: 639px) 100vw, 639px" data-recalc-dims="1" data-lazy-src="https://i1.wp.com/d331tpl5vusgqa.cloudfront.net/wp-content/uploads/2017/12/Code-smells-count.png?resize=639%2C199&amp;ssl=1" data-was-processed="true" width="639" height="199"></p>
<p style="text-align: justify;">In our code ‘testService.java’, we have used a sample system.out .print ln( ) method. In Sonar server, a rule is defined that mentions use logger instead of system.out.</p>
<p style="text-align: justify;">The below method main() is kept empty in ‘my testservice.java class’, as can be observed, SonarQube is recommending to comment on this method since this method is empty. Similarly, it shows other issues in the code.&nbsp;</p>
<p style="text-align: justify;"><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-3502 lazyloaded" src="https://i1.wp.com/d331tpl5vusgqa.cloudfront.net/wp-content/uploads/2017/12/testservice.png?resize=636%2C126&amp;ssl=1" sizes="auto, (max-width: 636px) 100vw, 636px" srcset="https://i0.wp.com/www.evoketechnologies.com/wp-content/uploads/2017/12/testservice.png?w=636&amp;ssl=1 636w, https://i0.wp.com/www.evoketechnologies.com/wp-content/uploads/2017/12/testservice.png?resize=300%2C59&amp;ssl=1 300w" alt="testservice" data-lazy-srcset="https://i0.wp.com/www.evoketechnologies.com/wp-content/uploads/2017/12/testservice.png?w=636&amp;ssl=1 636w, https://i0.wp.com/www.evoketechnologies.com/wp-content/uploads/2017/12/testservice.png?resize=300%2C59&amp;ssl=1 300w" data-lazy-sizes="(max-width: 636px) 100vw, 636px" data-recalc-dims="1" data-lazy-src="https://i1.wp.com/d331tpl5vusgqa.cloudfront.net/wp-content/uploads/2017/12/testservice.png?resize=636%2C126&amp;ssl=1" data-was-processed="true" width="636" height="126"></p>
<p style="text-align: justify;">Hope this post serves the purpose of providing insights on SonarQube integration, if you have any specific questions or comments, please feel free to post your comments.</p>
<p>The post <a href="http://kostacipo.stream/sonarqube-integration-with-jenkins-using-pipelines/">SonarQube Integration with Jenkins Using Pipelines</a> appeared first on <a href="http://kostacipo.stream">Tech Chronicles</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>http://kostacipo.stream/sonarqube-integration-with-jenkins-using-pipelines/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Creating a Secure Pipeline: Jenkins with SonarQube and DependencyCheck</title>
		<link>http://kostacipo.stream/creating-a-secure-pipeline-jenkins-with-sonarqube-and-dependencycheck/</link>
					<comments>http://kostacipo.stream/creating-a-secure-pipeline-jenkins-with-sonarqube-and-dependencycheck/#respond</comments>
		
		<dc:creator><![CDATA[Majordomo]]></dc:creator>
		<pubDate>Wed, 08 Jan 2020 10:45:34 +0000</pubDate>
				<category><![CDATA[DevOps]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[ci/cd]]></category>
		<category><![CDATA[jenkins]]></category>
		<category><![CDATA[owasp]]></category>
		<category><![CDATA[sonarqube]]></category>
		<guid isPermaLink="false">http://www.kostacipo.stream/?p=1639</guid>

					<description><![CDATA[<p>&#160; Configuring Jenkins To Build WebGoat We&#8217;re going to scan a known vulnerable webapp, WebGoat, which is an OWASP project used for learning basic web penetration testing skills and vulnerabilities. A good scanner should find a lot of things! A quick note: We were initially going to use Mutillidae, another vulnerable app written in PHP. [&#8230;]</p>
<p>The post <a href="http://kostacipo.stream/creating-a-secure-pipeline-jenkins-with-sonarqube-and-dependencycheck/">Creating a Secure Pipeline: Jenkins with SonarQube and DependencyCheck</a> appeared first on <a href="http://kostacipo.stream">Tech Chronicles</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>&nbsp;</p>
<h2 id="configuring-jenkins-to-build-webgoat">Configuring Jenkins To Build WebGoat</h2>
<p>We&#8217;re going to scan a known vulnerable webapp, <a href="https://webgoat.github.io/WebGoat/">WebGoat</a>, which is an OWASP project used for learning basic web penetration testing skills and vulnerabilities. A good scanner should find a lot of things!</p>
<p>A quick note: We were initially going to use <a href="https://github.com/webpwnized/mutillidae">Mutillidae</a>, another vulnerable app written in PHP. However we couldn&#8217;t find any good open source PHP Static analyzers that would catch the vulnerabilities. </p>
<p>Anyway, let&#8217;s get on with Jenkins. Navigate in your browser to <a href="http://localhost:8080">http://localhost:8080</a> and enter the admin password shown in the terminal running docker. Go ahead and install the default plugins (for a deployed instance, I would recommend only installing plugins you will actually use) and create your first admin user.</p>
<p>WebGoat requires Java 11 to build, which Jenkins won&#8217;t install automatically. Head over to the main page -&gt; Manage Jenkins -&gt; Global Tool Configuration. There are two sections here we will update now: JDK installation and Maven installations. We need to add a link to a Java 11 installer &#8211; we used <a href="https://download.java.net/java/GA/jdk11/13/GPL/openjdk-11.0.1_linux-x64_bin.tar.gz">https://download.java.net/java/GA/jdk11/13/GPL/openjdk-11.0.1_linux-x64_bin.tar.gz</a> and we can use the default maven. Your config should look like this:</p>
<figure class="kg-card kg-image-card kg-card-hascaption"><img decoding="async" class="kg-image" src="https://nullsweep.com/content/images/2019/05/jenkins_jdk_install_config.png"><figcaption>Jenkins JDK11 Install configuration</figcaption></figure>
<figure class="kg-card kg-image-card kg-card-hascaption"><img decoding="async" class="kg-image" src="https://nullsweep.com/content/images/2019/05/jenkins_maven_install_config.png"><figcaption>Jenkins Maven install configuration</figcaption></figure>
<p>We sometimes see Jenkins have trouble installing a JDK this way if more than one JDK is installed in the system. If this is the first one, there should be no problems.</p>
<p>Finally, we have to set the JAVA_HOME variable. In the Jenkins -&gt; Manage Jenkins -&gt; Configure System menu, enable environment varaibles and set JAVA_HOME equal to /var/jenkins_home/tools/hudson.model.JDK/openjdk11/jdk-11.0.1/.</p>
<p>Now let&#8217;s create a pipeline for WebGoat and make sure it builds successfully. Back on the main page choose new item -&gt; freestyle project.</p>
<p>The initial setup is pretty simple:</p>
<ul>
<li>Add Webgoat to the various github setting locations (https://github.com/WebGoat/WebGoat/)</li>
<li>Set the target branch to */develop</li>
<li>Create a maven build step (&#8220;Invoke top level maven targets&#8221;) and give it the command &#8220;clean install&#8221;</li>
</ul>
<p>Here is the full pipeline configuration:</p>
<figure class="kg-card kg-image-card kg-card-hascaption"><img decoding="async" class="kg-image" src="https://nullsweep.com/content/images/2019/05/initial_webgoat_pipeline.png"><figcaption>Basic WebGoat Pipeline</figcaption></figure>
<p>Try running it and making sure that everything builds successfully.</p>
<h2 id="adding-sonarqube-and-dependencycheck">Adding SonarQube and DependencyCheck</h2>
<h3 id="sonarqube-setup-security">SonarQube setup &amp; security</h3>
<p>We already have a SonarQube instance running, we just need to link and configure Jenkins to use it. Log in to <a href="http://localhost:9000">http://localhost:9000</a> and use the default sonarQube login of admin/admin.</p>
<p>Although this is only for practice, I still want to secure our SonarQube instance, so do the following:</p>
<ul>
<li>Change the admin password</li>
<li>Go to administration-&gt; security and turn on &#8220;Force user authentication&#8221;</li>
<li>Create a new user for Jenkins.</li>
<li>Log into the new user, go to the profile -&gt; security section, and generate a token. Copy this for later use.</li>
</ul>
<p>Finally, create a project named &#8220;webgoat&#8221; with your jenkins user.</p>
<h3 id="configure-the-plugins-for-jenkins">Configure the plugins for Jenkins</h3>
<p>We will need two new plugins for jenkins. In the Jenkins home page, go to Mange Jenkins -&gt; Manage Plugins. On the Available tab find and select &#8220;OWASP Dependency-Check Plugin&#8221; and &#8220;SonarQube Scanner for Jenkins&#8221;. Install them without restarting.</p>
<p>Back on the Jenkins home, go to Manage Jenkins -&gt; Global Tool Configuration. You should see a new option for SonarQube Scanner. Add an installation here (I just chose the latest from Maven Central) and save.</p>
<p>Finally, head over to Jenkins -&gt; Manage Jenkins -&gt; Configure System and add a sonarqube instance. The URL with our docker container is http://sonarqube:9000 and the token should be the one you saved while setting up the Jenkins user in SonarQube. Here is my setup:</p>
<figure class="kg-card kg-image-card kg-card-hascaption"><img decoding="async" class="kg-image" src="https://nullsweep.com/content/images/2019/05/sonarqube_settings.png"><figcaption>SonarQube Settings</figcaption></figure>
<p>One other thing I had to do to get SonarQube working properly. For some reason I couldn&#8217;t completely determine, the SonarQube startup script was truncating the JAVA_HOME path incorrectly, causing errors during the pipeline. To solve this, log into the docker container manually and update the sonar script to the proper JAVA_HOME.</p>
<pre class=" language-bash"><code class=" language-bash">$ docker <span class="token function">exec</span> -it secure_pipeline_jenkins_1 <span class="token function">bash</span>
jenkins@2ea0acb5905d:/$ <span class="token function">cd</span> /var/jenkins_home/tools/hudson.plugins.sonar.SonarRunnerInstallation/sonarqube
jenkins@2ea0acb5905d:~/tools/hudson.plugins.sonar.SonarRunnerInstallation/sonarqube$ <span class="token function">head</span> bin/sonar-scanner
<span class="token comment">#!/bin/sh</span>
<span class="token comment">#</span>
<span class="token comment"># SonarQube Scanner Startup Script for Unix</span>
<span class="token comment">#</span>
<span class="token comment"># Optional ENV vars:</span>
<span class="token comment">#   SONAR_SCANNER_OPTS - Parameters passed to the Java VM when running the SonarQube Scanner</span>
<span class="token comment">#   SONAR_SCANNER_DEBUG_OPTS - Extra parameters passed to the Java VM for debugging</span>
<span class="token comment">#   JAVA_HOME - Location of Java's installation</span>

JAVA_HOME<span class="token operator">=</span><span class="token string">"/var/jenkins_home/tools/hudson.model.JDK/openjdk11-remote/jdk-11.0.1"</span>
</code></pre>
<h3 id="add-sonarqube-and-dependencycheck-to-the-pipeline">Add SonarQube and DependencyCheck to the pipeline</h3>
<p>Now we can add these to our pipeline and start scanning with every build.</p>
<p>In the pipeline created earlier, add two new build steps &#8211; Invoke Dependency-Check analysis and Execute SonarQube Scanner. In the SonarQube scanner, add the configuration settings required &#8211; the project key and name should match the project you created in SonarQube.</p>
<pre class=" language-bash"><code class=" language-bash">sonar.projectKey<span class="token operator">=</span>webgoat
sonar.projectName<span class="token operator">=</span>webgoat
sonar.projectVersion<span class="token operator">=</span>1.0
sonar.language<span class="token operator">=</span>java
sonar.java.binaries<span class="token operator">=</span>**/target/classes
sonar.exclusions<span class="token operator">=</span>**/*.ts
</code></pre>
<p>I am excluding the TypeScript files above since we did not setup Node or a JS build step for our project. In a real project, we would want to ensure that they were also scannable.</p>
<p>In the DependencyCheck advanced section, check to generate HTML reports as well for easier viewing.</p>
<p>Here is my full pipeline configuration now:</p>
<figure class="kg-card kg-image-card kg-card-hascaption"><img decoding="async" class="kg-image" src="https://nullsweep.com/content/images/2019/05/webgoat_pipeline_with_sast.png"><figcaption>Full Secure Pipeline</figcaption></figure>
<p>Kick off a build and make sure it runs correctly. Afterwards, you should be able to see results.</p>
<h3 id="viewing-reports">Viewing Reports</h3>
<p>If all runs successfully, logging into SonarQube will show you security scan details (with plenty of findings!) and the pipeline can show you the dependencyCheck results in the workspace -&gt; dependency-check-report.html file.</p>
<figure class="kg-card kg-image-card kg-card-hascaption"><img decoding="async" class="kg-image" src="https://nullsweep.com/content/images/2019/05/dependencyCheck_results.png"><figcaption>DependencyCheck Sample Data</figcaption></figure>
<figure class="kg-card kg-image-card kg-card-hascaption"><img decoding="async" class="kg-image" src="https://nullsweep.com/content/images/2019/05/webgoat_sonarqube_report.png"><figcaption>SonarQube Findings</figcaption></figure>
<p>You can and should at this point consider additional SonarQube plugins (or other SAST tools) that are specifically for your languages and frameworks.</p>
<h2 id="breaking-the-build">Breaking the Build</h2>
<p>We want to know when something isn&#8217;t working right at the build phase. SonarQube gives us this for free with the plugin (you should see a nice red ERROR tag under the SonarQube Quality gate) but DependencyCheck requires one more configuration.</p>
<p>Add a post-build check for &#8220;Publish Dependency Check Results&#8221; and expand the advanced tabs. Just add some threshold data and the build will fail or be marked unstable according to the rules set.</p>
<p>Here &nbsp;is our final pipeline configuration, fully expanded.</p>
<figure class="kg-card kg-image-card"><img decoding="async" class="kg-image" src="https://nullsweep.com/content/images/2019/05/jenkins_full_sast.png"></figure>
<h2 id="final-thoughts">Final Thoughts</h2>
<p>Getting a CI/CD pipeline running with some basic security checks can be done within a few minutes. This will help keep your published artifacts in better shape and ensure the team has an opportunity to learn about security issues as soon as they emerge.</p>
<p>The post <a href="http://kostacipo.stream/creating-a-secure-pipeline-jenkins-with-sonarqube-and-dependencycheck/">Creating a Secure Pipeline: Jenkins with SonarQube and DependencyCheck</a> appeared first on <a href="http://kostacipo.stream">Tech Chronicles</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>http://kostacipo.stream/creating-a-secure-pipeline-jenkins-with-sonarqube-and-dependencycheck/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Setup SonarQube in OpenShift for scanning projects via Jenkins</title>
		<link>http://kostacipo.stream/setup-sonarqube-in-openshift-for-scanning-projects-via-jenkins/</link>
					<comments>http://kostacipo.stream/setup-sonarqube-in-openshift-for-scanning-projects-via-jenkins/#respond</comments>
		
		<dc:creator><![CDATA[Majordomo]]></dc:creator>
		<pubDate>Tue, 03 Dec 2019 09:30:25 +0000</pubDate>
				<category><![CDATA[DevOps]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[jenkins]]></category>
		<category><![CDATA[openshift]]></category>
		<category><![CDATA[sonarqube]]></category>
		<guid isPermaLink="false">http://www.kostacipo.stream/?p=1403</guid>

					<description><![CDATA[<p>&#160; When you have software development projects that you are building and running on Red Hat OpenShift you are probably testing them out locally with Minishift, getting the deployment correct, testing source-to-image or running your Dockerfile builds with environment variables to ensure your CI/CD pipeline is ready to roll. Or maybe you are testing out [&#8230;]</p>
<p>The post <a href="http://kostacipo.stream/setup-sonarqube-in-openshift-for-scanning-projects-via-jenkins/">Setup SonarQube in OpenShift for scanning projects via Jenkins</a> appeared first on <a href="http://kostacipo.stream">Tech Chronicles</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>&nbsp;</p>
<p>When you have software development projects that you are building and running on Red Hat OpenShift you are probably testing them out locally with Minishift, getting the deployment correct, testing source-to-image or running your Dockerfile builds with environment variables to ensure your CI/CD pipeline is ready to roll. Or maybe you are testing out platforms or containers and kubernetes and you want to get a good developer experience when doing it. You also could be testing out this DevOps thing people have been talking about for years and years.</p>
<p>One other thing to remember is the “Sec” part of DevSecOps: Sec = security. In my case, I use&nbsp;SonarQube locally and on my platform as part of my “Sec” steps to scan my projects and look for errors, vulnerabilities, bad coding practices, and the like. This post is to show how to setup SonarQube via a template within OpenShift (and Minishift) and call it from your Jenkins pipeline.</p>
<h4>Setup Minishift</h4>
<p>First things first, you need Minishift on your machine. I use a Mac for all my development so I used&nbsp;brew&nbsp;to install the latest Minishift executable. You can see other ways to setup Minishift&nbsp;here. I also use&nbsp;VirtualBox&nbsp;for my virtual machine driver for Minishift. I have a script that runs this for doing all my local Minishift development work that adds the vm-driver for VirtualBox, memory of 10GB, and disk-size of 40GB. I also run with the profile flag and save off the VM under a specific name so I can keep track of it. All personal preferences of course and you can run&nbsp;minishift -h&nbsp;to see the options. Figure out the options you wish to use and run minishift start with those options. It will pull down images, start the system, and give you information on how to log in. When that is up and running we are ready to setup SonarQube.</p>
<section class="cu cv cw cx cy">
<div class="n p">
<div class="ac ae af ag ah cz aj ak">
<div class="ho hp dr hq ak">
<div class="cl cm hh">
<div class="hw r dr hx">
<div class="hy r"><img loading="lazy" decoding="async" class="ly ns cp t u ht ak ic aligncenter" role="presentation" src="https://miro.medium.com/max/1080/1*4uS8R-v3dNo25Z_NIo_f7w.png" width="1080" height="20"></div>
</div>
</div>
</div>
<p style="text-align: center;" data-selectable-paragraph="">Minishift Command</p>
<h4>Optional: Enable the Admin-User AddOn</h4>
<p>This is optional but I like doing this locally. I enable the admin-user addon for Minishift. This lets you log in with ‘god’ rights. You can run&nbsp;minishift addon enable admin-user&nbsp;and then run&nbsp;minishift addon apply admin-user&nbsp;to do this. Once enabled and then applied you can login with admin/admin and see all the inner workings of Minishift and get a glimpse of what OpenShift has under the covers. There are other addons you can see by running the command&nbsp;minishift addons list&nbsp;as well. (Che is the other one I am testing out.)</p>
<h4>Setup the SonarQube Project</h4>
<p>Now that we have Minishift setup, you can go to the URL that was listed when you started it in the terminal window and login with admin/admin. Click the Create Project button on the top right and enter&nbsp;sonarqube&nbsp;(all lower case) for the Name field and&nbsp;SonarQube&nbsp;for the Display Name field. You can enter a description if you like to ensure you know what it is later when you look at the project listings.</p>
<div class="ho hp dr hq ak">
<div class="cl cm im">
<div class="hw r dr hx">
<div class="in r"><img loading="lazy" decoding="async" class="ly ns cp t u ht ak ic" role="presentation" src="https://miro.medium.com/max/1405/1*UpWhGpXocWCSrpAqQbbf2g.png" width="1405" height="878"></div>
</div>
</div>
</div>
<p style="text-align: center;" data-selectable-paragraph="">Add the SonarQube project on Minishift</p>
<p>Click the Create button and then click the SonarQube link that is created for you in the project listings. You will get to the blank screen for a Minishift project. From here you can deploy images, import deployment settings (we are doing this one), import other definitions in YAML format as well as select from templates in the catalog. I encourage you to see how you can&nbsp;import other templates, create your own templates for faster deployments, and get more familiar with this interface if you are going the OpenShift way.</p>
<p>I was inspired by the&nbsp;OpenShift Demos GH repo on SonarQube&nbsp;however I needed to update my image and persist data differently. So I went a different route. Not better or worse just different.</p>
<p>Now that you are in the SonarQube project click the “Import YAML / JSON” button and copy and paste&nbsp;this deployment from this GitHub repo. Click the Create button on the bottom right and ensure “Process the Template” is checked. Click Continue to get a listing of parameters. I will go into more detail later on these settings of saving data for the extensions (plugins), logs, temp space as well as the PostgreSQL database space.</p>
<p>You can adjust the space if you wish or just leave the defaults. I usually leave the database password field blank and it generates its own when I am doing local development.</p>
<p>When all is ready click the Create button and then the Close button and you will see a&nbsp;BUNCH&nbsp;of things were created. (Note the default SonarQube login is also admin/admin. If you keep this up you will want to change it OR link in oAuth, GitHub login, or Keycloak.)</p>
<p>What did we just do? Well we create a pod with a PostgreSQL image that when run exposes port 5432 internally to the project. We created a pod with a SonarQube 7.4-community image that when run exposes port 9000 through the https://sonarqube-sonarqube.x.x.x.x route. We have a database connection from SonarQube to PostgreSQL. And we have 5 areas of storage setup to persist data for these containers that are run: database data, SonarQube data, SonarQube extensions/plugins, SonarQube logs, and SonarQube temp space.</p>
<p>Do we need all of these? Maybe not if you want to write into the container and not keep it if it restarts. I do not like doing that. So I do it this way. Feel free to use and adjust to your will.</p>
<div class="ho hp dr hq ak">
<div class="cl cm ip">
<div class="hw r dr hx">
<div class="iq r"><img loading="lazy" decoding="async" class="ly ns cp t u ht ak ic" role="presentation" src="https://miro.medium.com/max/1406/1*R0LhdFVHPAJC7uYoYL_mCg.png" width="1406" height="874"></div>
</div>
</div>
</div>
<p style="text-align: center;" data-selectable-paragraph="">SonarQube 7.4 Community Edition setup in Minishift</p>
<h4>Let’s Dive In!</h4>
<p>To get more familiar with what our&nbsp;YAML&nbsp;file actually did we need to explore a little. We setup 2 deployments inside our project, one for each application. One application is SonarQube itself and we are using the image from&nbsp;DockerHub&nbsp;for that. The other application is PostgreSQL and OpenShift comes with that image already. So we just used it. If you click the Applications menu on the left and then Deployments you can see the 2 deployments we have. Click further on the links to see what each one has setup. For each deployment OpenShift will list #1, #2, #3 for the number of the deployment you have running. We just did this so you should see the #1 hyperlinked. Click on it to get something like the below image.</p>
<p>What you can see from the highlighted region are those storage listings, persistent volumes and persistent volume claims in Minishift language. This is telling OpenShift that for those areas of my container running (i.e. /opt/sonarqube/extensions) I want you to save that data in OpenShift to persist it. And as the container comes up or is redeployed mount this path inside the container for reuse. I am simplifying it however that is the gist of what this is doing. You also can see these Mounts going against the Storage listing under the Storage menu on the left. I tried to match the names to have them make sense for you.</p>
<h4>Log into SonarQube</h4>
<p>Go back to the Overview section of your project and you will see the&nbsp;https://sonarqube-sonarqube.x.x.x&nbsp;listing. This is the Route exposing a URL to the internal SonarQube container running. We only have a route for SonarQube. We do not need an external route for PostgreSQL as only SonarQube has to talk to it. Click that link and log in with admin/admin to ensure you can get to SonarQube. If it starts a tutorial click Skip this tutorial. You should get into SonarQube and see a screen like below. Now get to work!</p>
<h4>Use Jenkins in projects to scan code with SonarQube</h4>
<p>Having SonarQube is great and all&nbsp;only if you use it. I have an&nbsp;example microservice API project&nbsp;in dotnet core 2.1 that you could put into a brand new project and then use its&nbsp;deployment file&nbsp;to deploy 3 pods: Jenkins, the database, and the API. Then log into Jenkins, approve the OpenShift login, and see how Jenkins works within OpenShift. For SonarQube to work you need to add the SonarQube plugin on the Manage Jenkins → Manage Plugins page and restart. Then go into the Manage Jenkins → Configure System and setup the SonarQube plugin with the name if the server (i.e. SonarQube-Server), the internal-to-Openshift URL (i.e.&nbsp;http://sonarqube.sonarqube.svc), and a generated token from your account page so you can push scan results from the Jenkins process. You also could fork this project linked above and play around to get more familiar. The best way to learn is to do!</p>
<p>The steps on how to use SonarQube with Jenkins are&nbsp;here&nbsp;and are also all over Google.com and StackOverflow.com as well. To use that project linked above you have to load up some Jenkins slave images and update your Jenkinsfile to use them.</p>
<h4>Advanced: .NET Core Sonar Scanner Jenkins Slave</h4>
<p>There is a .Net Core SonarQube Scanner Jenkins slave image on this other repo&nbsp;that you can import by using the YAML files and importing into the ‘openshift’ project in OpenShift. You can use&nbsp;this project here to create in OpenShift to test it out. The Jenkins slave setup in the Jenkins Configure System screen will need to match the name of the labels in the Jenkinsfile. For now get used to SonarQube and see what you can do!</p>
</div>
</div>
</section>
<p>The post <a href="http://kostacipo.stream/setup-sonarqube-in-openshift-for-scanning-projects-via-jenkins/">Setup SonarQube in OpenShift for scanning projects via Jenkins</a> appeared first on <a href="http://kostacipo.stream">Tech Chronicles</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>http://kostacipo.stream/setup-sonarqube-in-openshift-for-scanning-projects-via-jenkins/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Install and configure Sonarqube on Linux (RHEL/Centos/ec2)</title>
		<link>http://kostacipo.stream/install-and-configure-sonarqube-on-linux-rhel-centos-ec2/</link>
		
		<dc:creator><![CDATA[Majordomo]]></dc:creator>
		<pubDate>Tue, 26 Nov 2019 10:14:56 +0000</pubDate>
				<category><![CDATA[DevOps]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[sonarqube]]></category>
		<guid isPermaLink="false">http://www.kostacipo.stream/?p=1371</guid>

					<description><![CDATA[<p>&#160; Sonarqube is a great tool for source code quality management, code analysis etc. This is the most widely used tool for code coverage and analysis. Install and &#160;Configure Sonarqube on Linux This guide will help you to set up and configure sonarqube&#160;on Linux servers (Redhat/Centos 7 versions) on any cloud platforms like ec2, azure, [&#8230;]</p>
<p>The post <a href="http://kostacipo.stream/install-and-configure-sonarqube-on-linux-rhel-centos-ec2/">Install and configure Sonarqube on Linux (RHEL/Centos/ec2)</a> appeared first on <a href="http://kostacipo.stream">Tech Chronicles</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>&nbsp;</p>
<p><a href="https://www.sonarqube.org/" target="_blank" rel="noopener noreferrer">Sonarqube</a> is a great tool for source code quality management, code analysis etc. This is the most widely used tool for code coverage and analysis.</p>
<h2>Install and &nbsp;Configure Sonarqube on Linux</h2>
<p>This guide will help you to set up and configure sonarqube&nbsp;on Linux servers (<strong>Redhat/Centos 7</strong> versions) on any cloud platforms like ec2, azure, compute engine or on-premise data centers. Follow the steps given below for the complete sonarqube configuration.</p>
<h3>Sonarqube requirements</h3>
<ol class="cool-list">
<li>Server with minimum 2GB/1 vcpu capacity</li>
<li>PostgreSQL version 9.3 or greater.</li>
<li>OpenJDK 11 or JRE 11</li>
<li>All sonarquber process should run as a non-root sonar user.</li>
</ol>
<p>You can find the official requirement <a href="https://docs.sonarqube.org/latest/requirements/requirements/" target="_blank" rel="noreferrer noopener" aria-label="doc here (opens in a new tab)">doc here</a>.</p>
<blockquote class="wp-block-quote"><p><strong>Update:</strong> MySQL for Sonarqube is depricated</p></blockquote>
<h3>Prep the Server With Required Softwares</h3>
<p><strong>Step 1:</strong> Update the server.</p>
<div id="crayon-5ddcf7f737dae614007637" class="crayon-syntax crayon-theme-prism-like crayon-font-monaco crayon-os-pc print-yes notranslate crayon-wrapped" data-settings=" minimize scroll-mouseover wrap">
<div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" readonly="readonly" data-settings="dblclick">sudo yum update -y</textarea></div>
<div class="crayon-main">
<table class="crayon-table">
<tbody>
<tr class="crayon-row">
<td class="crayon-nums " data-settings="hide">
<div class="crayon-nums-content">
<div class="crayon-num" data-line="crayon-5ddcf7f737dae614007637-1">1</div>
</div>
</td>
<td class="crayon-code">
<div class="crayon-pre">
<div id="crayon-5ddcf7f737dae614007637-1" class="crayon-line"><span class="crayon-e">sudo </span><span class="crayon-e">yum </span><span class="crayon-v">update</span> <span class="crayon-o">&#8211;</span><span class="crayon-v">y</span></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p><strong>Step 2:</strong> Install wget &amp; unzip</p>
<div id="crayon-5ddcf7f737db5240436427" class="crayon-syntax crayon-theme-prism-like crayon-font-monaco crayon-os-pc print-yes notranslate crayon-wrapped" data-settings=" minimize scroll-mouseover wrap">
<div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" readonly="readonly" data-settings="dblclick">sudo yum install wget unzip -y</textarea></div>
<div class="crayon-main">
<table class="crayon-table">
<tbody>
<tr class="crayon-row">
<td class="crayon-nums " data-settings="hide">
<div class="crayon-nums-content">
<div class="crayon-num" data-line="crayon-5ddcf7f737db5240436427-1">1</div>
</div>
</td>
<td class="crayon-code">
<div class="crayon-pre">
<div id="crayon-5ddcf7f737db5240436427-1" class="crayon-line"><span class="crayon-e">sudo </span><span class="crayon-e">yum </span><span class="crayon-e">install </span><span class="crayon-e">wget </span><span class="crayon-v">unzip</span> <span class="crayon-o">&#8211;</span><span class="crayon-v">y</span></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p><strong>Step 3:</strong> Install java 11</p>
<div id="crayon-5ddcf7f737db7024705391" class="crayon-syntax crayon-theme-prism-like crayon-font-monaco crayon-os-pc print-yes notranslate crayon-wrapped" data-settings=" minimize scroll-mouseover wrap">
<div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" readonly="readonly" data-settings="dblclick">sudo yum install java-11-openjdk-devel -y</textarea></div>
<div class="crayon-main">
<table class="crayon-table">
<tbody>
<tr class="crayon-row">
<td class="crayon-nums " data-settings="hide">
<div class="crayon-nums-content">
<div class="crayon-num" data-line="crayon-5ddcf7f737db7024705391-1">1</div>
</div>
</td>
<td class="crayon-code">
<div class="crayon-pre">
<div id="crayon-5ddcf7f737db7024705391-1" class="crayon-line"><span class="crayon-e">sudo </span><span class="crayon-e">yum </span><span class="crayon-e">install </span><span class="crayon-v">java</span><span class="crayon-o">&#8211;</span><span class="crayon-cn">11</span><span class="crayon-o">&#8211;</span><span class="crayon-v">openjdk</span><span class="crayon-o">&#8211;</span><span class="crayon-v">devel</span> <span class="crayon-o">&#8211;</span><span class="crayon-v">y</span></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p><strong>Step 4:</strong> Login as root and execute the following commands.</p>
<div id="crayon-5ddcf7f737db9152090487" class="crayon-syntax crayon-theme-prism-like crayon-font-monaco crayon-os-pc print-yes notranslate crayon-wrapped" data-settings=" minimize scroll-mouseover wrap">
<div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" readonly="readonly" data-settings="dblclick">sysctl vm.max_map_count<br />
sysctl fs.file-max<br />
ulimit -n<br />
ulimit -u</textarea></div>
<div class="crayon-main">
<table class="crayon-table">
<tbody>
<tr class="crayon-row">
<td class="crayon-nums " data-settings="hide">
<div class="crayon-nums-content">
<div class="crayon-num" data-line="crayon-5ddcf7f737db9152090487-1">1</div>
<div class="crayon-num crayon-striped-num" data-line="crayon-5ddcf7f737db9152090487-2">2</div>
<div class="crayon-num" data-line="crayon-5ddcf7f737db9152090487-3">3</div>
<div class="crayon-num crayon-striped-num" data-line="crayon-5ddcf7f737db9152090487-4">4</div>
</div>
</td>
<td class="crayon-code">
<div class="crayon-pre">
<div id="crayon-5ddcf7f737db9152090487-1" class="crayon-line"><span class="crayon-e">sysctl </span><span class="crayon-v">vm</span><span class="crayon-e">.max_map_count</span></div>
<div id="crayon-5ddcf7f737db9152090487-2" class="crayon-line crayon-striped-line"><span class="crayon-e">sysctl </span><span class="crayon-v">fs</span><span class="crayon-e">.file</span><span class="crayon-o">&#8211;</span><span class="crayon-e">max</span></div>
<div id="crayon-5ddcf7f737db9152090487-3" class="crayon-line"><span class="crayon-r">ulimit</span> <span class="crayon-o">&#8211;</span><span class="crayon-i">n</span></div>
<div id="crayon-5ddcf7f737db9152090487-4" class="crayon-line crayon-striped-line"><span class="crayon-r">ulimit</span> <span class="crayon-o">&#8211;</span><span class="crayon-v">u</span></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<h3>Setup PostgreSQL 10 Database For SonarQube</h3>
<p><strong>Step 1:</strong> Install PostgreSQL 10 repo.</p>
<div id="crayon-5ddcf7f737dba837800007" class="crayon-syntax crayon-theme-prism-like crayon-font-monaco crayon-os-pc print-yes notranslate crayon-wrapped" data-settings=" minimize scroll-mouseover wrap">
<div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" readonly="readonly" data-settings="dblclick">sudo yum install https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7-x86_64/pgdg-centos10-10-2.noarch.rpm -y</textarea></div>
<div class="crayon-main">
<table class="crayon-table">
<tbody>
<tr class="crayon-row">
<td class="crayon-nums " data-settings="hide">
<div class="crayon-nums-content">
<div class="crayon-num" data-line="crayon-5ddcf7f737dba837800007-1">1</div>
</div>
</td>
<td class="crayon-code">
<div class="crayon-pre">
<div id="crayon-5ddcf7f737dba837800007-1" class="crayon-line"><span class="crayon-e">sudo </span><span class="crayon-e">yum </span><span class="crayon-e">install </span><span class="crayon-v">https</span><span class="crayon-o">:</span><span class="crayon-o">/</span><span class="crayon-o">/</span><span class="crayon-v">download</span><span class="crayon-e">.postgresql</span><span class="crayon-e">.org</span><span class="crayon-o">/</span><span class="crayon-v">pub</span><span class="crayon-o">/</span><span class="crayon-v">repos</span><span class="crayon-o">/</span><span class="crayon-v">yum</span><span class="crayon-o">/</span><span class="crayon-cn">10</span><span class="crayon-o">/</span><span class="crayon-v">redhat</span><span class="crayon-o">/</span><span class="crayon-v">rhel</span><span class="crayon-o">&#8211;</span><span class="crayon-cn">7</span><span class="crayon-o">&#8211;</span><span class="crayon-v">x86_64</span><span class="crayon-o">/</span><span class="crayon-v">pgdg</span><span class="crayon-o">&#8211;</span><span class="crayon-v">centos10</span><span class="crayon-o">&#8211;</span><span class="crayon-cn">10</span><span class="crayon-o">&#8211;</span><span class="crayon-cn">2.noarch.rpm</span> <span class="crayon-o">&#8211;</span><span class="crayon-v">y</span></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p><strong>Step 2: </strong>Install PostgreSQL 10</p>
<div id="crayon-5ddcf7f737dbc840095638" class="crayon-syntax crayon-theme-prism-like crayon-font-monaco crayon-os-pc print-yes notranslate crayon-wrapped" data-settings=" minimize scroll-mouseover wrap">
<div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" readonly="readonly" data-settings="dblclick">sudo yum install postgresql10-server postgresql10-contrib -y</textarea></div>
<div class="crayon-main">
<table class="crayon-table">
<tbody>
<tr class="crayon-row">
<td class="crayon-nums " data-settings="hide">
<div class="crayon-nums-content">
<div class="crayon-num" data-line="crayon-5ddcf7f737dbc840095638-1">1</div>
</div>
</td>
<td class="crayon-code">
<div class="crayon-pre">
<div id="crayon-5ddcf7f737dbc840095638-1" class="crayon-line"><span class="crayon-e">sudo </span><span class="crayon-e">yum </span><span class="crayon-e">install </span><span class="crayon-v">postgresql10</span><span class="crayon-o">&#8211;</span><span class="crayon-e">server </span><span class="crayon-v">postgresql10</span><span class="crayon-o">&#8211;</span><span class="crayon-v">contrib</span> <span class="crayon-o">&#8211;</span><span class="crayon-v">y</span></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p><strong>Step 3:</strong> Initialize the database.</p>
<div id="crayon-5ddcf7f737dbe355229445" class="crayon-syntax crayon-theme-prism-like crayon-font-monaco crayon-os-pc print-yes notranslate crayon-wrapped" data-settings=" minimize scroll-mouseover wrap">
<div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" readonly="readonly" data-settings="dblclick">sudo /usr/pgsql-10/bin/postgresql-10-setup initdb</textarea></div>
<div class="crayon-main">
<table class="crayon-table">
<tbody>
<tr class="crayon-row">
<td class="crayon-nums " data-settings="hide">
<div class="crayon-nums-content">
<div class="crayon-num" data-line="crayon-5ddcf7f737dbe355229445-1">1</div>
</div>
</td>
<td class="crayon-code">
<div class="crayon-pre">
<div id="crayon-5ddcf7f737dbe355229445-1" class="crayon-line"><span class="crayon-v">sudo</span> <span class="crayon-o">/</span><span class="crayon-v">usr</span><span class="crayon-o">/</span><span class="crayon-v">pgsql</span><span class="crayon-o">&#8211;</span><span class="crayon-cn">10</span><span class="crayon-o">/</span><span class="crayon-v">bin</span><span class="crayon-o">/</span><span class="crayon-v">postgresql</span><span class="crayon-o">&#8211;</span><span class="crayon-cn">10</span><span class="crayon-o">&#8211;</span><span class="crayon-e">setup </span><span class="crayon-v">initdb</span></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p><strong>Step 4:</strong> Open /var/lib/pgsql/data/pg_hba.conf file to change the authentication to md5.</p>
<div id="crayon-5ddcf7f737dc0989726834" class="crayon-syntax crayon-theme-prism-like crayon-font-monaco crayon-os-pc print-yes notranslate crayon-wrapped" data-settings=" minimize scroll-mouseover wrap">
<div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" readonly="readonly" data-settings="dblclick">sudo vi /var/lib/pgsql/10/data/pg_hba.conf</textarea></div>
<div class="crayon-main">
<table class="crayon-table">
<tbody>
<tr class="crayon-row">
<td class="crayon-nums " data-settings="hide">
<div class="crayon-nums-content">
<div class="crayon-num" data-line="crayon-5ddcf7f737dc0989726834-1">1</div>
</div>
</td>
<td class="crayon-code">
<div class="crayon-pre">
<div id="crayon-5ddcf7f737dc0989726834-1" class="crayon-line"><span class="crayon-e">sudo </span><span class="crayon-r">vi</span> <span class="crayon-o">/</span><span class="crayon-t">var</span><span class="crayon-o">/</span><span class="crayon-v">lib</span><span class="crayon-o">/</span><span class="crayon-v">pgsql</span><span class="crayon-o">/</span><span class="crayon-cn">10</span><span class="crayon-o">/</span><span class="crayon-v">data</span><span class="crayon-o">/</span><span class="crayon-v">pg_hba</span><span class="crayon-e">.conf</span></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p>Find the following lines at the bottom of the file and change <code>peer</code>&nbsp;to&nbsp;<code>trust</code>&nbsp;and&nbsp;<code>idnet</code>&nbsp;to&nbsp;<code>md5</code></p>
<div id="crayon-5ddcf7f737dc1603631612" class="crayon-syntax crayon-theme-prism-like crayon-font-monaco crayon-os-pc print-yes notranslate crayon-wrapped" data-settings=" minimize scroll-mouseover wrap">
<div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" readonly="readonly" data-settings="dblclick"># TYPE  DATABASE        USER            ADDRESS                 METHOD</p>
<p># &#8220;local&#8221; is for Unix domain socket connections only<br />
local   all             all                                     peer<br />
# IPv4 local connections:<br />
host    all             all             127.0.0.1/32            ident<br />
# IPv6 local connections:<br />
host    all             all             ::1/128                 ident</textarea></div>
<div class="crayon-main">
<table class="crayon-table">
<tbody>
<tr class="crayon-row">
<td class="crayon-nums " data-settings="hide">
<div class="crayon-nums-content">
<div class="crayon-num" data-line="crayon-5ddcf7f737dc1603631612-1">1</div>
<div class="crayon-num crayon-striped-num" data-line="crayon-5ddcf7f737dc1603631612-2">2</div>
<div class="crayon-num" data-line="crayon-5ddcf7f737dc1603631612-3">3</div>
<div class="crayon-num crayon-striped-num" data-line="crayon-5ddcf7f737dc1603631612-4">4</div>
<div class="crayon-num" data-line="crayon-5ddcf7f737dc1603631612-5">5</div>
<div class="crayon-num crayon-striped-num" data-line="crayon-5ddcf7f737dc1603631612-6">6</div>
<div class="crayon-num" data-line="crayon-5ddcf7f737dc1603631612-7">7</div>
<div class="crayon-num crayon-striped-num" data-line="crayon-5ddcf7f737dc1603631612-8">8</div>
</div>
</td>
<td class="crayon-code">
<div class="crayon-pre">
<div id="crayon-5ddcf7f737dc1603631612-1" class="crayon-line"><span class="crayon-c"># TYPE&nbsp;&nbsp;DATABASE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;USER&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ADDRESS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; METHOD</span></div>
<div id="crayon-5ddcf7f737dc1603631612-2" class="crayon-line crayon-striped-line">&nbsp;</div>
<div id="crayon-5ddcf7f737dc1603631612-3" class="crayon-line"><span class="crayon-c"># &#8220;local&#8221; is for Unix domain socket connections only</span></div>
<div id="crayon-5ddcf7f737dc1603631612-4" class="crayon-line crayon-striped-line"><span class="crayon-e">local&nbsp;&nbsp; </span><span class="crayon-e">all&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span class="crayon-e">all&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span class="crayon-v">peer</span></div>
<div id="crayon-5ddcf7f737dc1603631612-5" class="crayon-line"><span class="crayon-c"># IPv4 local connections:</span></div>
<div id="crayon-5ddcf7f737dc1603631612-6" class="crayon-line crayon-striped-line"><span class="crayon-e">host&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-e">all&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span class="crayon-i">all</span><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span class="crayon-cn">127.0.0.1</span><span class="crayon-o">/</span><span class="crayon-cn">32</span><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-v">ident</span></div>
<div id="crayon-5ddcf7f737dc1603631612-7" class="crayon-line"><span class="crayon-c"># IPv6 local connections:</span></div>
<div id="crayon-5ddcf7f737dc1603631612-8" class="crayon-line crayon-striped-line"><span class="crayon-e">host&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-e">all&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span class="crayon-v">all</span><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span class="crayon-o">::</span><span class="crayon-cn">1</span><span class="crayon-o">/</span><span class="crayon-cn">128</span><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span class="crayon-v">ident</span></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p>Once changed, it should look like the following.</p>
<div id="crayon-5ddcf7f737dc3966473206" class="crayon-syntax crayon-theme-prism-like crayon-font-monaco crayon-os-pc print-yes notranslate crayon-wrapped" data-settings=" minimize scroll-mouseover wrap">
<div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" readonly="readonly" data-settings="dblclick"># TYPE  DATABASE        USER            ADDRESS                 METHOD</p>
<p># &#8220;local&#8221; is for Unix domain socket connections only<br />
local   all             all                                     trust<br />
# IPv4 local connections:<br />
host    all             all             127.0.0.1/32            md5<br />
# IPv6 local connections:<br />
host    all             all             ::1/128                 md5</textarea></div>
<div class="crayon-main">
<table class="crayon-table">
<tbody>
<tr class="crayon-row">
<td class="crayon-nums " data-settings="hide">
<div class="crayon-nums-content">
<div class="crayon-num" data-line="crayon-5ddcf7f737dc3966473206-1">1</div>
<div class="crayon-num crayon-striped-num" data-line="crayon-5ddcf7f737dc3966473206-2">2</div>
<div class="crayon-num" data-line="crayon-5ddcf7f737dc3966473206-3">3</div>
<div class="crayon-num crayon-striped-num" data-line="crayon-5ddcf7f737dc3966473206-4">4</div>
<div class="crayon-num" data-line="crayon-5ddcf7f737dc3966473206-5">5</div>
<div class="crayon-num crayon-striped-num" data-line="crayon-5ddcf7f737dc3966473206-6">6</div>
<div class="crayon-num" data-line="crayon-5ddcf7f737dc3966473206-7">7</div>
<div class="crayon-num crayon-striped-num" data-line="crayon-5ddcf7f737dc3966473206-8">8</div>
</div>
</td>
<td class="crayon-code">
<div class="crayon-pre">
<div id="crayon-5ddcf7f737dc3966473206-1" class="crayon-line"><span class="crayon-c"># TYPE&nbsp;&nbsp;DATABASE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;USER&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ADDRESS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; METHOD</span></div>
<div id="crayon-5ddcf7f737dc3966473206-2" class="crayon-line crayon-striped-line">&nbsp;</div>
<div id="crayon-5ddcf7f737dc3966473206-3" class="crayon-line"><span class="crayon-c"># &#8220;local&#8221; is for Unix domain socket connections only</span></div>
<div id="crayon-5ddcf7f737dc3966473206-4" class="crayon-line crayon-striped-line"><span class="crayon-e">local&nbsp;&nbsp; </span><span class="crayon-e">all&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span class="crayon-e">all&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span class="crayon-v">trust</span></div>
<div id="crayon-5ddcf7f737dc3966473206-5" class="crayon-line"><span class="crayon-c"># IPv4 local connections:</span></div>
<div id="crayon-5ddcf7f737dc3966473206-6" class="crayon-line crayon-striped-line"><span class="crayon-e">host&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-e">all&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span class="crayon-i">all</span><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span class="crayon-cn">127.0.0.1</span><span class="crayon-o">/</span><span class="crayon-cn">32</span><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-v">md5</span></div>
<div id="crayon-5ddcf7f737dc3966473206-7" class="crayon-line"><span class="crayon-c"># IPv6 local connections:</span></div>
<div id="crayon-5ddcf7f737dc3966473206-8" class="crayon-line crayon-striped-line"><span class="crayon-e">host&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-e">all&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span class="crayon-v">all</span><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span class="crayon-o">::</span><span class="crayon-cn">1</span><span class="crayon-o">/</span><span class="crayon-cn">128</span><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span class="crayon-v">md5</span></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p><strong>Step 5: </strong>Start and enable PostgreSQL.</p>
<div id="crayon-5ddcf7f737dc5207876541" class="crayon-syntax crayon-theme-prism-like crayon-font-monaco crayon-os-pc print-yes notranslate crayon-wrapped" data-settings=" minimize scroll-mouseover wrap">
<div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" readonly="readonly" data-settings="dblclick">sudo systemctl start postgresql-10<br />
sudo systemctl enable postgresql-10</textarea></div>
<div class="crayon-main">
<table class="crayon-table">
<tbody>
<tr class="crayon-row">
<td class="crayon-nums " data-settings="hide">
<div class="crayon-nums-content">
<div class="crayon-num" data-line="crayon-5ddcf7f737dc5207876541-1">1</div>
<div class="crayon-num crayon-striped-num" data-line="crayon-5ddcf7f737dc5207876541-2">2</div>
</div>
</td>
<td class="crayon-code">
<div class="crayon-pre">
<div id="crayon-5ddcf7f737dc5207876541-1" class="crayon-line"><span class="crayon-e">sudo </span><span class="crayon-e">systemctl </span><span class="crayon-e">start </span><span class="crayon-v">postgresql</span><span class="crayon-o">&#8211;</span><span class="crayon-cn">10</span></div>
<div id="crayon-5ddcf7f737dc5207876541-2" class="crayon-line crayon-striped-line"><span class="crayon-e">sudo </span><span class="crayon-e">systemctl </span><span class="crayon-e">enable </span><span class="crayon-v">postgresql</span><span class="crayon-o">&#8211;</span><span class="crayon-cn">10</span></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p><strong>Step 6:</strong> You can verify the installation using the following version select query.</p>
<div id="crayon-5ddcf7f737dc7944451865" class="crayon-syntax crayon-theme-prism-like crayon-font-monaco crayon-os-pc print-yes notranslate crayon-wrapped" data-settings=" minimize scroll-mouseover wrap">
<div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" readonly="readonly" data-settings="dblclick">sudo -u postgres /usr/pgsql-10/bin/psql -c &#8220;SELECT version();&#8221;</textarea></div>
<div class="crayon-main">
<table class="crayon-table">
<tbody>
<tr class="crayon-row">
<td class="crayon-nums " data-settings="hide">
<div class="crayon-nums-content">
<div class="crayon-num" data-line="crayon-5ddcf7f737dc7944451865-1">1</div>
</div>
</td>
<td class="crayon-code">
<div class="crayon-pre">
<div id="crayon-5ddcf7f737dc7944451865-1" class="crayon-line"><span class="crayon-v">sudo</span> <span class="crayon-o">&#8211;</span><span class="crayon-i">u</span> <span class="crayon-v">postgres</span> <span class="crayon-o">/</span><span class="crayon-v">usr</span><span class="crayon-o">/</span><span class="crayon-v">pgsql</span><span class="crayon-o">&#8211;</span><span class="crayon-cn">10</span><span class="crayon-o">/</span><span class="crayon-v">bin</span><span class="crayon-o">/</span><span class="crayon-v">psql</span> <span class="crayon-o">&#8211;</span><span class="crayon-i">c</span> <span class="crayon-s">&#8220;SELECT version();&#8221;</span></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<h3>Setup Sonar User and Database</h3>
<p>We need to have a sonar user and database for the sonar application.</p>
<p><strong>Step 1:</strong> Change the default password of the Postgres user. All Postgres commands have to be executed from this user.</p>
<div id="crayon-5ddcf7f737dc9859624962" class="crayon-syntax crayon-theme-prism-like crayon-font-monaco crayon-os-pc print-yes notranslate crayon-wrapped" data-settings=" minimize scroll-mouseover wrap">
<div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" readonly="readonly" data-settings="dblclick">sudo passwd postgres</textarea></div>
<div class="crayon-main">
<table class="crayon-table">
<tbody>
<tr class="crayon-row">
<td class="crayon-nums " data-settings="hide">
<div class="crayon-nums-content">
<div class="crayon-num" data-line="crayon-5ddcf7f737dc9859624962-1">1</div>
</div>
</td>
<td class="crayon-code">
<div class="crayon-pre">
<div id="crayon-5ddcf7f737dc9859624962-1" class="crayon-line"><span class="crayon-e">sudo </span><span class="crayon-e">passwd </span><span class="crayon-v">postgres</span></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p><strong>Step 2:</strong> Login as postgres user with the new password.</p>
<div id="crayon-5ddcf7f737dcb914815630" class="crayon-syntax crayon-theme-prism-like crayon-font-monaco crayon-os-pc print-yes notranslate crayon-wrapped" data-settings=" minimize scroll-mouseover wrap">
<div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" readonly="readonly" data-settings="dblclick">su &#8211; postgres</textarea></div>
<div class="crayon-main">
<table class="crayon-table">
<tbody>
<tr class="crayon-row">
<td class="crayon-nums " data-settings="hide">
<div class="crayon-nums-content">
<div class="crayon-num" data-line="crayon-5ddcf7f737dcb914815630-1">1</div>
</div>
</td>
<td class="crayon-code">
<div class="crayon-pre">
<div id="crayon-5ddcf7f737dcb914815630-1" class="crayon-line"><span class="crayon-v">su</span> <span class="crayon-o">&#8211;</span> <span class="crayon-v">postgres</span></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p><strong>Step 3:</strong> Login to the PostgreSQL CLI.</p>
<div id="crayon-5ddcf7f737dcc536202047" class="crayon-syntax crayon-theme-prism-like crayon-font-monaco crayon-os-pc print-yes notranslate crayon-wrapped" data-settings=" minimize scroll-mouseover wrap">
<div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" readonly="readonly" data-settings="dblclick">psql</textarea></div>
<div class="crayon-main">
<table class="crayon-table">
<tbody>
<tr class="crayon-row">
<td class="crayon-nums " data-settings="hide">
<div class="crayon-nums-content">
<div class="crayon-num" data-line="crayon-5ddcf7f737dcc536202047-1">1</div>
</div>
</td>
<td class="crayon-code">
<div class="crayon-pre">
<div id="crayon-5ddcf7f737dcc536202047-1" class="crayon-line"><span class="crayon-v">psql</span></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p><strong>Step 4:</strong> Create a sonarqubedb database.</p>
<div id="crayon-5ddcf7f737dce948275066" class="crayon-syntax crayon-theme-prism-like crayon-font-monaco crayon-os-pc print-yes notranslate crayon-wrapped" data-settings=" minimize scroll-mouseover wrap">
<div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" readonly="readonly" data-settings="dblclick">create database sonarqubedb;</textarea></div>
<div class="crayon-main">
<table class="crayon-table">
<tbody>
<tr class="crayon-row">
<td class="crayon-nums " data-settings="hide">
<div class="crayon-nums-content">
<div class="crayon-num" data-line="crayon-5ddcf7f737dce948275066-1">1</div>
</div>
</td>
<td class="crayon-code">
<div class="crayon-pre">
<div id="crayon-5ddcf7f737dce948275066-1" class="crayon-line"><span class="crayon-e">create </span><span class="crayon-e">database </span><span class="crayon-v">sonarqubedb</span><span class="crayon-sy">;</span></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p><strong>Step 5:</strong> Create the sonarqube DB user with a strongly encrypted password. Replace your-strong-password with a strong password.</p>
<div id="crayon-5ddcf7f737dd0395267206" class="crayon-syntax crayon-theme-prism-like crayon-font-monaco crayon-os-pc print-yes notranslate crayon-wrapped" data-settings=" minimize scroll-mouseover wrap">
<div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" readonly="readonly" data-settings="dblclick">create user sonarqube with encrypted password &#8216;your-strong-password&#8217;;</textarea></div>
<div class="crayon-main">
<table class="crayon-table">
<tbody>
<tr class="crayon-row">
<td class="crayon-nums " data-settings="hide">
<div class="crayon-nums-content">
<div class="crayon-num" data-line="crayon-5ddcf7f737dd0395267206-1">1</div>
</div>
</td>
<td class="crayon-code">
<div class="crayon-pre">
<div id="crayon-5ddcf7f737dd0395267206-1" class="crayon-line"><span class="crayon-e">create </span><span class="crayon-e">user </span><span class="crayon-e">sonarqube </span><span class="crayon-e">with </span><span class="crayon-e">encrypted </span><span class="crayon-i">password</span> <span class="crayon-s">&#8216;your-strong-password&#8217;</span><span class="crayon-sy">;</span></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p><strong>Step 6:</strong> Next, grant all privileges to sonrqube user on sonarqubedb.</p>
<div id="crayon-5ddcf7f737dd1294834535" class="crayon-syntax crayon-theme-prism-like crayon-font-monaco crayon-os-pc print-yes notranslate crayon-wrapped" data-settings=" minimize scroll-mouseover wrap">
<div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" readonly="readonly" data-settings="dblclick">grant all privileges on database sonarqubedb to sonarqube</textarea></div>
<div class="crayon-main">
<table class="crayon-table">
<tbody>
<tr class="crayon-row">
<td class="crayon-nums " data-settings="hide">
<div class="crayon-nums-content">
<div class="crayon-num" data-line="crayon-5ddcf7f737dd1294834535-1">1</div>
</div>
</td>
<td class="crayon-code">
<div class="crayon-pre">
<div id="crayon-5ddcf7f737dd1294834535-1" class="crayon-line"><span class="crayon-e">grant </span><span class="crayon-e">all </span><span class="crayon-e">privileges </span><span class="crayon-e">on </span><span class="crayon-e">database </span><span class="crayon-e">sonarqubedb </span><span class="crayon-st">to</span> <span class="crayon-v">sonarqube</span></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p><strong>Step 7:</strong> Exit the psql prompt using the following command.</p>
<div id="crayon-5ddcf7f737dd3861989588" class="crayon-syntax crayon-theme-prism-like crayon-font-monaco crayon-os-pc print-yes notranslate crayon-wrapped" data-settings=" minimize scroll-mouseover wrap">
<div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" readonly="readonly" data-settings="dblclick">\q</textarea></div>
<div class="crayon-main">
<table class="crayon-table">
<tbody>
<tr class="crayon-row">
<td class="crayon-nums " data-settings="hide">
<div class="crayon-nums-content">
<div class="crayon-num" data-line="crayon-5ddcf7f737dd3861989588-1">1</div>
</div>
</td>
<td class="crayon-code">
<div class="crayon-pre">
<div id="crayon-5ddcf7f737dd3861989588-1" class="crayon-line"><span class="crayon-sy">\</span><span class="crayon-v">q</span></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p>Step 6: Switch to your sudo user using the exit command.</p>
<div id="crayon-5ddcf7f737dd5424531849" class="crayon-syntax crayon-theme-prism-like crayon-font-monaco crayon-os-pc print-yes notranslate crayon-wrapped" data-settings=" minimize scroll-mouseover wrap">
<div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" readonly="readonly" data-settings="dblclick">exit</textarea></div>
<div class="crayon-main">
<table class="crayon-table">
<tbody>
<tr class="crayon-row">
<td class="crayon-nums " data-settings="hide">
<div class="crayon-nums-content">
<div class="crayon-num" data-line="crayon-5ddcf7f737dd5424531849-1">1</div>
</div>
</td>
<td class="crayon-code">
<div class="crayon-pre">
<div id="crayon-5ddcf7f737dd5424531849-1" class="crayon-line"><span class="crayon-r">exit</span></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<h3>Setup Sonarqube Web Server</h3>
<p><strong>Step 1:</strong> Download the latest sonarqube installation file to /opt folder. You can get the latest download link from here. http://www.sonarqube.org/downloads/</p>
<div id="crayon-5ddcf7f737dd6908377617" class="crayon-syntax crayon-theme-prism-like crayon-font-monaco crayon-os-pc print-yes notranslate crayon-wrapped" data-settings=" minimize scroll-mouseover wrap">
<div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" readonly="readonly" data-settings="dblclick">cd /opt<br />
sudo wget https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-7.6.zip</textarea></div>
<div class="crayon-main">
<table class="crayon-table">
<tbody>
<tr class="crayon-row">
<td class="crayon-nums " data-settings="hide">
<div class="crayon-nums-content">
<div class="crayon-num" data-line="crayon-5ddcf7f737dd6908377617-1">1</div>
<div class="crayon-num crayon-striped-num" data-line="crayon-5ddcf7f737dd6908377617-2">2</div>
</div>
</td>
<td class="crayon-code">
<div class="crayon-pre">
<div id="crayon-5ddcf7f737dd6908377617-1" class="crayon-line"><span class="crayon-r">cd</span> <span class="crayon-o">/</span><span class="crayon-e">opt </span></div>
<div id="crayon-5ddcf7f737dd6908377617-2" class="crayon-line crayon-striped-line"><span class="crayon-e">sudo </span><span class="crayon-e">wget </span><span class="crayon-v">https</span><span class="crayon-o">:</span><span class="crayon-o">/</span><span class="crayon-o">/</span><span class="crayon-v">binaries</span><span class="crayon-e">.sonarsource</span><span class="crayon-e">.com</span><span class="crayon-o">/</span><span class="crayon-v">Distribution</span><span class="crayon-o">/</span><span class="crayon-v">sonarqube</span><span class="crayon-o">/</span><span class="crayon-v">sonarqube</span><span class="crayon-o">&#8211;</span><span class="crayon-cn">7.6.zip</span></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p>2. Unzip sonarqube source files and rename the folder.</p>
<div id="crayon-5ddcf7f737dd8207142902" class="crayon-syntax crayon-theme-prism-like crayon-font-monaco crayon-os-pc print-yes notranslate crayon-wrapped" data-settings=" minimize scroll-mouseover wrap">
<div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" readonly="readonly" data-settings="dblclick">sudo unzip sonarqube-7.6.zip<br />
sudo mv sonarqube-7.6 sonarqube</textarea></div>
<div class="crayon-main">
<table class="crayon-table">
<tbody>
<tr class="crayon-row">
<td class="crayon-nums " data-settings="hide">
<div class="crayon-nums-content">
<div class="crayon-num" data-line="crayon-5ddcf7f737dd8207142902-1">1</div>
<div class="crayon-num crayon-striped-num" data-line="crayon-5ddcf7f737dd8207142902-2">2</div>
</div>
</td>
<td class="crayon-code">
<div class="crayon-pre">
<div id="crayon-5ddcf7f737dd8207142902-1" class="crayon-line"><span class="crayon-e">sudo </span><span class="crayon-e">unzip </span><span class="crayon-v">sonarqube</span><span class="crayon-o">&#8211;</span><span class="crayon-cn">7.6.zip</span></div>
<div id="crayon-5ddcf7f737dd8207142902-2" class="crayon-line crayon-striped-line"><span class="crayon-e">sudo </span><span class="crayon-r">mv</span> <span class="crayon-v">sonarqube</span><span class="crayon-o">&#8211;</span><span class="crayon-cn">7.6</span> <span class="crayon-v">sonarqube</span></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p>4. Open /opt/sonarqube/conf/sonar.properties file.</p>
<div id="crayon-5ddcf7f737dda721229992" class="crayon-syntax crayon-theme-prism-like crayon-font-monaco crayon-os-pc print-yes notranslate crayon-wrapped" data-settings=" minimize scroll-mouseover wrap">
<div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" readonly="readonly" data-settings="dblclick">sudo vi /opt/sonarqube/conf/sonar.properties</textarea></div>
<div class="crayon-main">
<table class="crayon-table">
<tbody>
<tr class="crayon-row">
<td class="crayon-nums " data-settings="hide">
<div class="crayon-nums-content">
<div class="crayon-num" data-line="crayon-5ddcf7f737dda721229992-1">1</div>
</div>
</td>
<td class="crayon-code">
<div class="crayon-pre">
<div id="crayon-5ddcf7f737dda721229992-1" class="crayon-line"><span class="crayon-e">sudo </span><span class="crayon-r">vi</span> <span class="crayon-o">/</span><span class="crayon-v">opt</span><span class="crayon-o">/</span><span class="crayon-v">sonarqube</span><span class="crayon-o">/</span><span class="crayon-v">conf</span><span class="crayon-o">/</span><span class="crayon-v">sonar</span><span class="crayon-e">.properties</span></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p>Uncomment and edit the parameters as shown below. Change the password accordingly. You will find jdbc parameter under PostgreSQL section.</p>
<div id="crayon-5ddcf7f737ddc032282541" class="crayon-syntax crayon-theme-prism-like crayon-font-monaco crayon-os-pc print-yes notranslate crayon-wrapped" data-settings=" minimize scroll-mouseover wrap">
<div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" readonly="readonly" data-settings="dblclick">sonar.jdbc.username=sonar<br />
sonar.jdbc.password=sonar-db-password<br />
sonar.jdbc.url=jdbc:postgresql://localhost/sonar</textarea></div>
<div class="crayon-main">
<table class="crayon-table">
<tbody>
<tr class="crayon-row">
<td class="crayon-nums " data-settings="hide">
<div class="crayon-nums-content">
<div class="crayon-num" data-line="crayon-5ddcf7f737ddc032282541-1">1</div>
<div class="crayon-num crayon-striped-num" data-line="crayon-5ddcf7f737ddc032282541-2">2</div>
<div class="crayon-num" data-line="crayon-5ddcf7f737ddc032282541-3">3</div>
</div>
</td>
<td class="crayon-code">
<div class="crayon-pre">
<div id="crayon-5ddcf7f737ddc032282541-1" class="crayon-line"><span class="crayon-v">sonar</span><span class="crayon-e">.jdbc</span><span class="crayon-e">.username</span><span class="crayon-o">=</span><span class="crayon-e">sonar&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></div>
<div id="crayon-5ddcf7f737ddc032282541-2" class="crayon-line crayon-striped-line"><span class="crayon-v">sonar</span><span class="crayon-e">.jdbc</span><span class="crayon-e">.password</span><span class="crayon-o">=</span><span class="crayon-v">sonar</span><span class="crayon-o">&#8211;</span><span class="crayon-v">db</span><span class="crayon-o">&#8211;</span><span class="crayon-e">password</span></div>
<div id="crayon-5ddcf7f737ddc032282541-3" class="crayon-line"><span class="crayon-v">sonar</span><span class="crayon-e">.jdbc</span><span class="crayon-e">.url</span><span class="crayon-o">=</span><span class="crayon-v">jdbc</span><span class="crayon-o">:</span><span class="crayon-v">postgresql</span><span class="crayon-o">:</span><span class="crayon-o">/</span><span class="crayon-o">/</span><span class="crayon-v">localhost</span><span class="crayon-o">/</span><span class="crayon-v">sonar</span></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p>By default, sonar will run on 9000. If you want on port 80 or any other port, change the following parameters for accessing the web console on that specific port.</p>
<div id="crayon-5ddcf7f737dde819036373" class="crayon-syntax crayon-theme-prism-like crayon-font-monaco crayon-os-pc print-yes notranslate crayon-wrapped" data-settings=" minimize scroll-mouseover wrap">
<div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" readonly="readonly" data-settings="dblclick">sonar.web.host=0.0.0.0<br />
sonar.web.port=80</textarea></div>
<div class="crayon-main">
<table class="crayon-table">
<tbody>
<tr class="crayon-row">
<td class="crayon-nums " data-settings="hide">
<div class="crayon-nums-content">
<div class="crayon-num" data-line="crayon-5ddcf7f737dde819036373-1">1</div>
<div class="crayon-num crayon-striped-num" data-line="crayon-5ddcf7f737dde819036373-2">2</div>
</div>
</td>
<td class="crayon-code">
<div class="crayon-pre">
<div id="crayon-5ddcf7f737dde819036373-1" class="crayon-line"><span class="crayon-v">sonar</span><span class="crayon-e">.web</span><span class="crayon-e">.host</span><span class="crayon-o">=</span><span class="crayon-cn">0.0.0.0</span></div>
<div id="crayon-5ddcf7f737dde819036373-2" class="crayon-line crayon-striped-line"><span class="crayon-v">sonar</span><span class="crayon-e">.web</span><span class="crayon-e">.port</span><span class="crayon-o">=</span><span class="crayon-cn">80</span></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p>If you want to access sonarqube some path like http://url:/sonar, change the following parameter.</p>
<div id="crayon-5ddcf7f737ddf473169575" class="crayon-syntax crayon-theme-prism-like crayon-font-monaco crayon-os-pc print-yes notranslate crayon-wrapped" data-settings=" minimize scroll-mouseover wrap">
<div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" readonly="readonly" data-settings="dblclick">sonar.web.context=/sonar</textarea></div>
<div class="crayon-main">
<table class="crayon-table">
<tbody>
<tr class="crayon-row">
<td class="crayon-nums " data-settings="hide">
<div class="crayon-nums-content">
<div class="crayon-num" data-line="crayon-5ddcf7f737ddf473169575-1">1</div>
</div>
</td>
<td class="crayon-code">
<div class="crayon-pre">
<div id="crayon-5ddcf7f737ddf473169575-1" class="crayon-line"><span class="crayon-v">sonar</span><span class="crayon-e">.web</span><span class="crayon-e">.context</span><span class="crayon-o">=</span><span class="crayon-o">/</span><span class="crayon-v">sonar</span></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<h3>Add Sonar User and Privileges</h3>
<p>Create a user named sonar and make it the owner of the <code>/opt/sonarqube</code> directory.</p>
<div id="crayon-5ddcf7f737de1195545044" class="crayon-syntax crayon-theme-prism-like crayon-font-monaco crayon-os-pc print-yes notranslate crayon-wrapped" data-settings=" minimize scroll-mouseover wrap">
<div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" readonly="readonly" data-settings="dblclick">sudo useradd sonar<br />
sudo chown -R sonar:sonar /opt/sonarqube</textarea></div>
<div class="crayon-main">
<table class="crayon-table">
<tbody>
<tr class="crayon-row">
<td class="crayon-nums " data-settings="hide">
<div class="crayon-nums-content">
<div class="crayon-num" data-line="crayon-5ddcf7f737de1195545044-1">1</div>
<div class="crayon-num crayon-striped-num" data-line="crayon-5ddcf7f737de1195545044-2">2</div>
</div>
</td>
<td class="crayon-code">
<div class="crayon-pre">
<div id="crayon-5ddcf7f737de1195545044-1" class="crayon-line"><span class="crayon-e">sudo </span><span class="crayon-e">useradd </span><span class="crayon-e">sonar</span></div>
<div id="crayon-5ddcf7f737de1195545044-2" class="crayon-line crayon-striped-line"><span class="crayon-e">sudo </span><span class="crayon-r">chown</span> <span class="crayon-o">&#8211;</span><span class="crayon-i">R</span> <span class="crayon-v">sonar</span><span class="crayon-o">:</span><span class="crayon-v">sonar</span> <span class="crayon-o">/</span><span class="crayon-v">opt</span><span class="crayon-o">/</span><span class="crayon-v">sonarqube</span></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<h3>Start Sonarqube Service</h3>
<p>To start sonar service, you need to use the script in sonarqube bin directory.</p>
<p><strong>Step 1:</strong> Login as sonar user</p>
<div id="crayon-5ddcf7f737de3086725828" class="crayon-syntax crayon-theme-prism-like crayon-font-monaco crayon-os-pc print-yes notranslate crayon-wrapped" data-settings=" minimize scroll-mouseover wrap">
<div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" readonly="readonly" data-settings="dblclick">sudo su &#8211; sonar</textarea></div>
<div class="crayon-main">
<table class="crayon-table">
<tbody>
<tr class="crayon-row">
<td class="crayon-nums " data-settings="hide">
<div class="crayon-nums-content">
<div class="crayon-num" data-line="crayon-5ddcf7f737de3086725828-1">1</div>
</div>
</td>
<td class="crayon-code">
<div class="crayon-pre">
<div id="crayon-5ddcf7f737de3086725828-1" class="crayon-line"><span class="crayon-e">sudo </span><span class="crayon-v">su</span> <span class="crayon-o">&#8211;</span> <span class="crayon-v">sonar</span></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p><strong>Step 2:</strong> Navigate to the start script directory.</p>
<div id="crayon-5ddcf7f737de4557336994" class="crayon-syntax crayon-theme-prism-like crayon-font-monaco crayon-os-pc print-yes notranslate crayon-wrapped" data-settings=" minimize scroll-mouseover wrap">
<div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" readonly="readonly" data-settings="dblclick">cd /opt/sonarqube/bin/linux-x86-64 </textarea></div>
<div class="crayon-main">
<table class="crayon-table">
<tbody>
<tr class="crayon-row">
<td class="crayon-nums " data-settings="hide">
<div class="crayon-nums-content">
<div class="crayon-num" data-line="crayon-5ddcf7f737de4557336994-1">1</div>
</div>
</td>
<td class="crayon-code">
<div class="crayon-pre">
<div id="crayon-5ddcf7f737de4557336994-1" class="crayon-line"><span class="crayon-r">cd</span> <span class="crayon-o">/</span><span class="crayon-v">opt</span><span class="crayon-o">/</span><span class="crayon-v">sonarqube</span><span class="crayon-o">/</span><span class="crayon-v">bin</span><span class="crayon-o">/</span><span class="crayon-v">linux</span><span class="crayon-o">&#8211;</span><span class="crayon-v">x86</span><span class="crayon-o">&#8211;</span><span class="crayon-cn">64</span></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p><strong>Step 3:</strong> Start the sonarqube service.</p>
<div id="crayon-5ddcf7f737de6439183603" class="crayon-syntax crayon-theme-prism-like crayon-font-monaco crayon-os-pc print-yes notranslate crayon-wrapped" data-settings=" minimize scroll-mouseover wrap">
<div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" readonly="readonly" data-settings="dblclick">./sonar.sh start</textarea></div>
<div class="crayon-main">
<table class="crayon-table">
<tbody>
<tr class="crayon-row">
<td class="crayon-nums " data-settings="hide">
<div class="crayon-nums-content">
<div class="crayon-num" data-line="crayon-5ddcf7f737de6439183603-1">1</div>
</div>
</td>
<td class="crayon-code">
<div class="crayon-pre">
<div id="crayon-5ddcf7f737de6439183603-1" class="crayon-line"><span class="crayon-sy">.</span><span class="crayon-o">/</span><span class="crayon-v">sonar</span><span class="crayon-e">.sh</span> <span class="crayon-v">start</span></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p>Now, you should be able to access sonarqube on the browser on port 9000</p>
<p><strong>Step 4: </strong>Check the application status. If it is in running state, you can access the sonarqube dashboard using the DNS name or Ip address of your server.</p>
<div id="crayon-5ddcf7f737de8383832596" class="crayon-syntax crayon-theme-prism-like crayon-font-monaco crayon-os-pc print-yes notranslate crayon-wrapped" data-settings=" minimize scroll-mouseover wrap">
<div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" readonly="readonly" data-settings="dblclick">sudo ./sonar.sh status</textarea></div>
<div class="crayon-main">
<table class="crayon-table">
<tbody>
<tr class="crayon-row">
<td class="crayon-nums " data-settings="hide">
<div class="crayon-nums-content">
<div class="crayon-num" data-line="crayon-5ddcf7f737de8383832596-1">1</div>
</div>
</td>
<td class="crayon-code">
<div class="crayon-pre">
<div id="crayon-5ddcf7f737de8383832596-1" class="crayon-line"><span class="crayon-i">sudo</span> <span class="crayon-sy">.</span><span class="crayon-o">/</span><span class="crayon-v">sonar</span><span class="crayon-e">.sh</span> <span class="crayon-v">status</span></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<h3>Setting up Sonarqube as a service</h3>
<p><strong>Step 1</strong>: Create a file <code>/etc/systemd/system/sonarqube.service</code></p>
<div id="crayon-5ddcf7f737dea579508852" class="crayon-syntax crayon-theme-prism-like crayon-font-monaco crayon-os-pc print-yes notranslate crayon-wrapped" data-settings=" minimize scroll-mouseover wrap">
<div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" readonly="readonly" data-settings="dblclick">sudo vi /etc/systemd/system/sonarqube.service</textarea></div>
<div class="crayon-main">
<table class="crayon-table">
<tbody>
<tr class="crayon-row">
<td class="crayon-nums " data-settings="hide">
<div class="crayon-nums-content">
<div class="crayon-num" data-line="crayon-5ddcf7f737dea579508852-1">1</div>
</div>
</td>
<td class="crayon-code">
<div class="crayon-pre">
<div id="crayon-5ddcf7f737dea579508852-1" class="crayon-line"><span class="crayon-e">sudo </span><span class="crayon-r">vi</span> <span class="crayon-o">/</span><span class="crayon-v">etc</span><span class="crayon-o">/</span><span class="crayon-v">systemd</span><span class="crayon-o">/</span><span class="crayon-v">system</span><span class="crayon-o">/</span><span class="crayon-v">sonarqube</span><span class="crayon-e">.service</span></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p>Step 2: Copy the following content on to the file.</p>
<div id="crayon-5ddcf7f737dec728814309" class="crayon-syntax crayon-theme-prism-like crayon-font-monaco crayon-os-pc print-yes notranslate crayon-wrapped" data-settings=" minimize scroll-mouseover wrap">
<div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" readonly="readonly" data-settings="dblclick">[Unit]
Description=SonarQube service<br />
After=syslog.target network.target</p>
[Service]
Type=simple<br />
User=sonarqube<br />
Group=sonarqube<br />
PermissionsStartOnly=true<br />
ExecStart=/bin/nohup java -Xms32m -Xmx32m -Djava.net.preferIPv4Stack=true -jar /opt/sonarqube/lib/sonar-application-7.6.jar<br />
StandardOutput=syslog<br />
LimitNOFILE=65536<br />
LimitNPROC=8192<br />
TimeoutStartSec=5<br />
Restart=always</p>
[Install]
WantedBy=multi-user.target</textarea></div>
<div class="crayon-main">
<table class="crayon-table">
<tbody>
<tr class="crayon-row">
<td class="crayon-nums " data-settings="hide">
<div class="crayon-nums-content">
<div class="crayon-num" data-line="crayon-5ddcf7f737dec728814309-1">1</div>
<div class="crayon-num crayon-striped-num" data-line="crayon-5ddcf7f737dec728814309-2">2</div>
<div class="crayon-num" data-line="crayon-5ddcf7f737dec728814309-3">3</div>
<div class="crayon-num crayon-striped-num" data-line="crayon-5ddcf7f737dec728814309-4">4</div>
<div class="crayon-num" data-line="crayon-5ddcf7f737dec728814309-5">5</div>
<div class="crayon-num crayon-striped-num" data-line="crayon-5ddcf7f737dec728814309-6">6</div>
<div class="crayon-num" data-line="crayon-5ddcf7f737dec728814309-7">7</div>
<div class="crayon-num crayon-striped-num" data-line="crayon-5ddcf7f737dec728814309-8">8</div>
<div class="crayon-num" data-line="crayon-5ddcf7f737dec728814309-9">9</div>
<div class="crayon-num crayon-striped-num" data-line="crayon-5ddcf7f737dec728814309-10">10</div>
<div class="crayon-num" data-line="crayon-5ddcf7f737dec728814309-11">11</div>
<div class="crayon-num crayon-striped-num" data-line="crayon-5ddcf7f737dec728814309-12">12</div>
<div class="crayon-num" data-line="crayon-5ddcf7f737dec728814309-13">13</div>
<div class="crayon-num crayon-striped-num" data-line="crayon-5ddcf7f737dec728814309-14">14</div>
<div class="crayon-num" data-line="crayon-5ddcf7f737dec728814309-15">15</div>
<div class="crayon-num crayon-striped-num" data-line="crayon-5ddcf7f737dec728814309-16">16</div>
<div class="crayon-num" data-line="crayon-5ddcf7f737dec728814309-17">17</div>
<div class="crayon-num crayon-striped-num" data-line="crayon-5ddcf7f737dec728814309-18">18</div>
</div>
</td>
<td class="crayon-code">
<div class="crayon-pre">
<div id="crayon-5ddcf7f737dec728814309-1" class="crayon-line"><span class="crayon-sy">[</span><span class="crayon-v">Unit</span><span class="crayon-sy">]</span></div>
<div id="crayon-5ddcf7f737dec728814309-2" class="crayon-line crayon-striped-line"><span class="crayon-v">Description</span><span class="crayon-o">=</span><span class="crayon-e">SonarQube </span><span class="crayon-e">service</span></div>
<div id="crayon-5ddcf7f737dec728814309-3" class="crayon-line"><span class="crayon-v">After</span><span class="crayon-o">=</span><span class="crayon-v">syslog</span><span class="crayon-e">.target</span> <span class="crayon-v">network</span><span class="crayon-e">.target</span></div>
<div id="crayon-5ddcf7f737dec728814309-4" class="crayon-line crayon-striped-line">&nbsp;</div>
<div id="crayon-5ddcf7f737dec728814309-5" class="crayon-line"><span class="crayon-sy">[</span><span class="crayon-v">Service</span><span class="crayon-sy">]</span></div>
<div id="crayon-5ddcf7f737dec728814309-6" class="crayon-line crayon-striped-line"><span class="crayon-r">Type</span><span class="crayon-o">=</span><span class="crayon-e">simple</span></div>
<div id="crayon-5ddcf7f737dec728814309-7" class="crayon-line"><span class="crayon-v">User</span><span class="crayon-o">=</span><span class="crayon-e">sonarqube</span></div>
<div id="crayon-5ddcf7f737dec728814309-8" class="crayon-line crayon-striped-line"><span class="crayon-v">Group</span><span class="crayon-o">=</span><span class="crayon-e">sonarqube</span></div>
<div id="crayon-5ddcf7f737dec728814309-9" class="crayon-line"><span class="crayon-v">PermissionsStartOnly</span><span class="crayon-o">=</span><span class="crayon-t">true</span></div>
<div id="crayon-5ddcf7f737dec728814309-10" class="crayon-line crayon-striped-line"><span class="crayon-v">ExecStart</span><span class="crayon-o">=</span><span class="crayon-o">/</span><span class="crayon-v">bin</span><span class="crayon-o">/</span><span class="crayon-r">nohup</span> <span class="crayon-v">java</span> <span class="crayon-o">&#8211;</span><span class="crayon-v">Xms32m</span> <span class="crayon-o">&#8211;</span><span class="crayon-v">Xmx32m</span> <span class="crayon-o">&#8211;</span><span class="crayon-v">Djava</span><span class="crayon-e">.net</span><span class="crayon-e">.preferIPv4Stack</span><span class="crayon-o">=</span><span class="crayon-t">true</span> <span class="crayon-o">&#8211;</span><span class="crayon-v">jar</span> <span class="crayon-o">/</span><span class="crayon-v">opt</span><span class="crayon-o">/</span><span class="crayon-v">sonarqube</span><span class="crayon-o">/</span><span class="crayon-v">lib</span><span class="crayon-o">/</span><span class="crayon-v">sonar</span><span class="crayon-o">&#8211;</span><span class="crayon-v">application</span><span class="crayon-o">&#8211;</span><span class="crayon-cn">7.6.jar</span></div>
<div id="crayon-5ddcf7f737dec728814309-11" class="crayon-line"><span class="crayon-v">StandardOutput</span><span class="crayon-o">=</span><span class="crayon-e">syslog</span></div>
<div id="crayon-5ddcf7f737dec728814309-12" class="crayon-line crayon-striped-line"><span class="crayon-v">LimitNOFILE</span><span class="crayon-o">=</span><span class="crayon-cn">65536</span></div>
<div id="crayon-5ddcf7f737dec728814309-13" class="crayon-line"><span class="crayon-v">LimitNPROC</span><span class="crayon-o">=</span><span class="crayon-cn">8192</span></div>
<div id="crayon-5ddcf7f737dec728814309-14" class="crayon-line crayon-striped-line"><span class="crayon-v">TimeoutStartSec</span><span class="crayon-o">=</span><span class="crayon-cn">5</span></div>
<div id="crayon-5ddcf7f737dec728814309-15" class="crayon-line"><span class="crayon-v">Restart</span><span class="crayon-o">=</span><span class="crayon-i">always</span></div>
<div id="crayon-5ddcf7f737dec728814309-16" class="crayon-line crayon-striped-line">&nbsp;</div>
<div id="crayon-5ddcf7f737dec728814309-17" class="crayon-line"><span class="crayon-sy">[</span><span class="crayon-v">Install</span><span class="crayon-sy">]</span></div>
<div id="crayon-5ddcf7f737dec728814309-18" class="crayon-line crayon-striped-line"><span class="crayon-v">WantedBy</span><span class="crayon-o">=</span><span class="crayon-v">multi</span><span class="crayon-o">&#8211;</span><span class="crayon-v">user</span><span class="crayon-e">.target</span></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p><strong>Step 3:</strong> Start and enable sonarqube</p>
<div id="crayon-5ddcf7f737dee312161982" class="crayon-syntax crayon-theme-prism-like crayon-font-monaco crayon-os-pc print-yes notranslate crayon-wrapped" data-settings=" minimize scroll-mouseover wrap">
<div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" readonly="readonly" data-settings="dblclick">sudo systemctl start sonarqube<br />
sudo systemctl enable sonarqube</textarea></div>
<div class="crayon-main">
<table class="crayon-table">
<tbody>
<tr class="crayon-row">
<td class="crayon-nums " data-settings="hide">
<div class="crayon-nums-content">
<div class="crayon-num" data-line="crayon-5ddcf7f737dee312161982-1">1</div>
<div class="crayon-num crayon-striped-num" data-line="crayon-5ddcf7f737dee312161982-2">2</div>
</div>
</td>
<td class="crayon-code">
<div class="crayon-pre">
<div id="crayon-5ddcf7f737dee312161982-1" class="crayon-line"><span class="crayon-e">sudo </span><span class="crayon-e">systemctl </span><span class="crayon-e">start </span><span class="crayon-e">sonarqube</span></div>
<div id="crayon-5ddcf7f737dee312161982-2" class="crayon-line crayon-striped-line"><span class="crayon-e">sudo </span><span class="crayon-e">systemctl </span><span class="crayon-e">enable </span><span class="crayon-v">sonarqube</span></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p><strong>Step 4:</strong> Check the sonarqube status to ensure it is running as expected.</p>
<div id="crayon-5ddcf7f737def409252088" class="crayon-syntax crayon-theme-prism-like crayon-font-monaco crayon-os-pc print-yes notranslate crayon-wrapped" data-settings=" minimize scroll-mouseover wrap">
<div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" readonly="readonly" data-settings="dblclick">sudo systemctl status  sonarqube</textarea></div>
<div class="crayon-main">
<table class="crayon-table">
<tbody>
<tr class="crayon-row">
<td class="crayon-nums " data-settings="hide">
<div class="crayon-nums-content">
<div class="crayon-num" data-line="crayon-5ddcf7f737def409252088-1">1</div>
</div>
</td>
<td class="crayon-code">
<div class="crayon-pre">
<div id="crayon-5ddcf7f737def409252088-1" class="crayon-line"><span class="crayon-e">sudo </span><span class="crayon-e">systemctl </span><span class="crayon-e">status&nbsp;&nbsp;</span><span class="crayon-v">sonarqube</span></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<h3>Troubleshooting Sonarqube</h3>
<p>All the logs of sonarqube are present in the <code>/opt/sonarqube/logs</code> directory.</p>
<div id="crayon-5ddcf7f737dfd331473314" class="crayon-syntax crayon-theme-prism-like crayon-font-monaco crayon-os-pc print-yes notranslate crayon-wrapped" data-settings=" minimize scroll-mouseover wrap">
<div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" readonly="readonly" data-settings="dblclick">cd /opt/sonarqube/logs</textarea></div>
<div class="crayon-main">
<table class="crayon-table">
<tbody>
<tr class="crayon-row">
<td class="crayon-nums " data-settings="hide">
<div class="crayon-nums-content">
<div class="crayon-num" data-line="crayon-5ddcf7f737dfd331473314-1">1</div>
</div>
</td>
<td class="crayon-code">
<div class="crayon-pre">
<div id="crayon-5ddcf7f737dfd331473314-1" class="crayon-line"><span class="crayon-r">cd</span> <span class="crayon-o">/</span><span class="crayon-v">opt</span><span class="crayon-o">/</span><span class="crayon-v">sonarqube</span><span class="crayon-o">/</span><span class="crayon-v">logs</span></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p>You can find the following log files.</p>
<div id="crayon-5ddcf7f737dfe688716133" class="crayon-syntax crayon-theme-prism-like crayon-font-monaco crayon-os-pc print-yes notranslate crayon-wrapped" data-settings=" minimize scroll-mouseover wrap">
<div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" readonly="readonly" data-settings="dblclick">es.log<br />
sonar.log<br />
web.log<br />
access.log</textarea></div>
<div class="crayon-main">
<table class="crayon-table">
<tbody>
<tr class="crayon-row">
<td class="crayon-nums " data-settings="hide">
<div class="crayon-nums-content">
<div class="crayon-num" data-line="crayon-5ddcf7f737dfe688716133-1">1</div>
<div class="crayon-num crayon-striped-num" data-line="crayon-5ddcf7f737dfe688716133-2">2</div>
<div class="crayon-num" data-line="crayon-5ddcf7f737dfe688716133-3">3</div>
<div class="crayon-num crayon-striped-num" data-line="crayon-5ddcf7f737dfe688716133-4">4</div>
</div>
</td>
<td class="crayon-code">
<div class="crayon-pre">
<div id="crayon-5ddcf7f737dfe688716133-1" class="crayon-line"><span class="crayon-v">es</span><span class="crayon-e">.log</span></div>
<div id="crayon-5ddcf7f737dfe688716133-2" class="crayon-line crayon-striped-line"><span class="crayon-v">sonar</span><span class="crayon-e">.log</span></div>
<div id="crayon-5ddcf7f737dfe688716133-3" class="crayon-line"><span class="crayon-v">web</span><span class="crayon-e">.log</span></div>
<div id="crayon-5ddcf7f737dfe688716133-4" class="crayon-line crayon-striped-line"><span class="crayon-v">access</span><span class="crayon-e">.log</span></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p>Using tail command you can check the latest logs. For example,</p>
<div id="crayon-5ddcf7f737e00890798225" class="crayon-syntax crayon-theme-prism-like crayon-font-monaco crayon-os-pc print-yes notranslate crayon-wrapped" data-settings=" minimize scroll-mouseover wrap">
<div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" readonly="readonly" data-settings="dblclick">tail -f access.log</textarea></div>
<div class="crayon-main">
<table class="crayon-table">
<tbody>
<tr class="crayon-row">
<td class="crayon-nums " data-settings="hide">
<div class="crayon-nums-content">
<div class="crayon-num" data-line="crayon-5ddcf7f737e00890798225-1">1</div>
</div>
</td>
<td class="crayon-code">
<div class="crayon-pre">
<div id="crayon-5ddcf7f737e00890798225-1" class="crayon-line"><span class="crayon-r">tail</span> <span class="crayon-o">&#8211;</span><span class="crayon-i">f</span> <span class="crayon-v">access</span><span class="crayon-e">.log</span></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p>For sonarqube support, visit<a href="https://www.sonarqube.org/get-support/" target="_blank" rel="noopener noreferrer"> this link</a></p>
<p>The post <a href="http://kostacipo.stream/install-and-configure-sonarqube-on-linux-rhel-centos-ec2/">Install and configure Sonarqube on Linux (RHEL/Centos/ec2)</a> appeared first on <a href="http://kostacipo.stream">Tech Chronicles</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>SonarQube Scanning in 15 Minutes</title>
		<link>http://kostacipo.stream/this-is-the-perfect-spot-if-you-need-peace-and-quiet/</link>
					<comments>http://kostacipo.stream/this-is-the-perfect-spot-if-you-need-peace-and-quiet/#respond</comments>
		
		<dc:creator><![CDATA[Majordomo]]></dc:creator>
		<pubDate>Fri, 18 Jan 2019 13:35:55 +0000</pubDate>
				<category><![CDATA[DevOps]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[sonarqube]]></category>
		<guid isPermaLink="false">https://demo.mekshq.com/johannes/dc/?p=159</guid>

					<description><![CDATA[<p>&#160; Step 1: Install Docker Download Docker here if you&#8217;re not running it already, &#38; install it. Docker containers are simply the best way to test out new tools with minimum fuss, in my opinion. Step 2: Install SonarQube Community and Start It Up You can do this by running the following 2 commands:   [&#8230;]</p>
<p>The post <a href="http://kostacipo.stream/this-is-the-perfect-spot-if-you-need-peace-and-quiet/">SonarQube Scanning in 15 Minutes</a> appeared first on <a href="http://kostacipo.stream">Tech Chronicles</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>&nbsp;</p>

<h3><strong>Step 1: Install Docker</strong></h3>
<p>Download Docker here if you&#8217;re not running it already, &amp; install it. Docker containers are simply the best way to test out new tools with minimum fuss, in my opinion.</p>
<h3><strong>Step 2: Install SonarQube Community and Start It Up</strong></h3>
<p>You can do this by running the following 2 commands:</p>
<div class="CodeMirror cm-s-default">
<div class="CodeMirror-scroll">
<div class="CodeMirror-sizer">
<div>
<div class="CodeMirror-lines">
<div>
<div class="CodeMirror-code">
<div>
<div class="CodeMirror-gutter-wrapper">
<div class="CodeMirror-linenumber CodeMirror-gutter-elt" data-line-number="1"> </div>
</div>
<pre>docker pull sonarqube </pre>
</div>
<div>
<div class="CodeMirror-gutter-wrapper">
<div class="CodeMirror-linenumber CodeMirror-gutter-elt" data-line-number="2"> </div>
</div>
<pre>docker run <span class="cm-attribute">-d</span> <span class="cm-attribute">--name</span> sonarqube <span class="cm-attribute">-p</span> <span class="cm-number">9000</span>:9000 <span class="cm-attribute">-p</span> <span class="cm-number">9092</span>:9092 sonarqube</pre>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="CodeMirror-gutters">
<div class="CodeMirror-gutter CodeMirror-linenumbers"> </div>
</div>
</div>
</div>
<p>Now, you can browse to http://localhost:9000, and you&#8217;ll be looking at the SonarQube Web GUI.</p>
<p>Easy, right?</p>
<p><img decoding="async" class="fr-fin fr-dib" src="https://dzone.com/storage/temp/9063701-screen-shot-2018-05-08-at-100224-am.png" alt="Image title" width="829" /></p>
<p>Login with: admin/admin. Note the warning in red. This Docker image relies on an embedded H2 database that won&#8217;t handle a production environment. If you want to run a more production-like container, and you understand how docker-compose works, then you can find a recipe for adding PostgreSQL as the datastore here.</p>
<p>When you load the SonarQube webpage, you&#8217;ll be presented with a tutorial screen. Go ahead and generate a token. I named mine, &#8220;my-stinky-php-files.&#8221; Very original. Copy this token to your clipboard. We&#8217;ll use it later.</p>
<p>Most everyone uses SonarQube to analyze Java files. That&#8217;s too easy. For the tutorial, let&#8217;s choose a different language. Choose &#8220;Other.&#8221; Pick your OS. In my case, I&#8217;m running Debian Stretch, so I&#8217;ll choose, &#8220;Linux.&#8221; My unique project key will be &#8220;my-stinky-php-files.&#8221; I happen to have too many of these. Since we are not running this instance in a pipeline, and since we&#8217;ll be scanning some PHP code, we will download the CLI scanner. Unzip this into the folder: /opt/sonar-scanner-3.1.0.1141-linux.</p>
<p>You can check out the plugins while you are downloading the required companion scanner software. Note that you may see references to SonarQube Runner. <em>Runner</em> is simply the old name for <em>Scanner</em>.</p>
<p>From this point on we will be working in a Linux environment. Scanners are available for 64-bit versions of Windows, MacOS, Linux, and Any*. Moreover, you can choose to download &amp; install a number of SonarQube scanners depending upon which language(s) you want to analyze or how you want to launch your scanner instances. These include scanners for MSBuild, Maven, Gradle, Ant, and Jenkins.</p>
<p>Now, change to your sonar-scanner/conf directory. For me the path is, &#8220;/opt/sonar-scanner-3.1.0.1141-linux/conf&#8221;. There is not much to configure. Unless you&#8217;ve changed the listening Docker ports you only have to delete the # sign at the start of the sonar.host.url line.</p>
<div class="CodeMirror cm-s-default">
<div class="CodeMirror-scroll">
<div class="CodeMirror-sizer">
<div>
<div class="CodeMirror-lines">
<div>
<div class="CodeMirror-code">
<div>
<div class="CodeMirror-gutter-wrapper">
<div class="CodeMirror-linenumber CodeMirror-gutter-elt" data-line-number="1"> </div>
</div>
<pre> <span class="cm-comment">#----- Default SonarQube server</span></pre>
</div>
<div>
<div class="CodeMirror-gutter-wrapper">
<div class="CodeMirror-linenumber CodeMirror-gutter-elt" data-line-number="2"> </div>
</div>
<pre><span class="cm-comment">#sonar.host.://localhost:9000</span></pre>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="CodeMirror-gutters">
<div class="CodeMirror-gutter CodeMirror-linenumbers"> </div>
</div>
</div>
</div>
<p>Next, add the Sonar Scanner /bin directory to your path:</p>
<div class="CodeMirror cm-s-default">
<div class="CodeMirror-scroll">
<div class="CodeMirror-sizer">
<div>
<div class="CodeMirror-lines">
<div>
<div class="CodeMirror-code">
<div>
<div class="CodeMirror-gutter-wrapper">
<div class="CodeMirror-linenumber CodeMirror-gutter-elt" data-line-number="1"> </div>
</div>
<pre> <span class="cm-keyword">export</span> \ <span class="cm-def">PATH</span><span class="cm-operator">=</span><span class="cm-def">$PATH</span>:/opt/sonar-scanner-3.1.0.1141-linux/bin</pre>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="CodeMirror-gutters">
<div class="CodeMirror-gutter CodeMirror-linenumbers"> </div>
</div>
</div>
</div>
<p>If you want to add this PATH permanently, then make the change in your ~/.profile file. If you don&#8217;t do this, you will run into problems later – problems, in the sense that shell will not be able to locate sonar-scanner. You can verify that everything has gone right to this point by opening a new shell (or by sourcing your .profile if you chose that route) and executing the command <code>sonar-scanner -h</code> (on Windows the command is  <code>sonar-scanner.bat -h</code>). You will see some usage options.</p>
<p>One last thing to note when running the community edition of SonarQube. As far as I know, there is no way to generate reports as PDF&#8217;s or XML. You have to pay for that functionality.</p>
<h3><strong>Step 3: Let&#8217;s Start Scanning</strong></h3>
<p>Let&#8217;s see how ugly** my code really is.</p>
<p>When you use SonarQube, sadly you just can&#8217;t push a button and send it off to happily scan whatever software you&#8217;re evaluating. You have to do a bit of command-line work to get things moving. Fortunately, SonarQube provides you with a default scanning framework that will get you started. However, for most your particular projects you will likely tweak this framework to fit the project. For example, you may want to enter other directories, point to a particular set of Java binaries, etc.</p>
<p>In the case of this tutorial, we&#8217;ll go with the simple code that Sonar provides for us.</p>
<div class="CodeMirror cm-s-default">
<div class="CodeMirror-scroll">
<div class="CodeMirror-sizer">
<div>
<div class="CodeMirror-lines">
<div>
<div class="CodeMirror-code">
<div>
<pre>/opt/sonar-scanner/bin/sonar-scanner \</pre>
</div>
<div>
<pre>  <span class="cm-attribute">-Dsonar</span><span class="cm-def">.projectKey</span><span class="cm-operator">=</span> my-stinky-php-files \</pre>
</div>
<div>
<pre>  <span class="cm-attribute">-Dsonar</span><span class="cm-def">.sources</span><span class="cm-operator">=</span>. \</pre>
</div>
<div>
<pre>  <span class="cm-attribute">-Dsonar</span>.host.://localhost:9000 \</pre>
</div>
<div>
<pre>  <span class="cm-attribute">-Dsonar</span>.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</pre>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="CodeMirror-gutters">
<div class="CodeMirror-gutter CodeMirror-linenumbers"> </div>
</div>
</div>
</div>
<p>Let&#8217;s break this command down.</p>
<p>First, for the Linux-challenged out there, the “\&#8221; (space-backslash) command indicates that the command continues over several lines.</p>
<p> <code>/opt/sonar-scanner/bin/sonar-scanner \</code><span id="_tmp_pre_6"> </span> initiates the scanning process (If this isn&#8217;t in your $PATH, you&#8217;ll get an error stating that the file cannot be found)</p>
<p> <code>-Dsonar.-stinky-php-files</code><span id="_tmp_pre_7"> </span> is a token that describes the set of file(s) that we are scanning. This name must be unique in a given SonarQube instance</p>
<p> <code>-Dsonar.sources=. \</code>  is the location on disk of the files we will scan. If you&#8217;re not scanning from the folder that contains your files, provide an absolute path to that location. Replace &#8220;\&#8221; by &#8220;/&#8221; on Windows.</p>
<p> <code>-Dsonar.host.://localhost:9000 \</code><span id="_tmp_pre_9"> </span> is the URI and port of our SonarQube web GUI</p>
<p> <code>-Dsonar.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</code><span id="_tmp_pre_10"> </span> is the token we generated earlier that uniquely identifies you. This is the point that may befuddle some users when they start running regular scans.</p>
<p>If you intend to run a scan on a different project, or if you’ve had to reload your SonarQube docker instance, or if you’ve simply forgotten your token, go to the web GUI: Click on the <em>administration</em> tab. From there, click on the <em>security </em>drop-down box, and choose <em>Users. </em>If this is your first installation, then you&#8217;ll see the Administrator user. To the right of the Groups legend, you&#8217;ll see a <em>Token</em> legend. Click on this to generate a new token.</p>
<p>Now, let’s change to the directory that contains the files we want to scan and run the command above. Note, neither your project key nor token will be the same as mine.</p>
<h3><strong>Step 4: Now for the Pretty Stuff</strong></h3>
<p>If you&#8217;ve followed along so far, you&#8217;ll see some text run past, and, depending upon the number of files that you scan, it will take a few seconds to a few minutes to complete the scan. If, for some reason you can&#8217;t get to the Web GUI, check that the SonarQube container is running by typing:  <code>docker ps</code><span id="_tmp_pre_2"> </span>.</p>
<p>You should see a response similar to that below. If you don&#8217;t then you&#8217;ll need to restart your container.</p>
<div class="CodeMirror cm-s-default">
<div class="CodeMirror-scroll">
<div class="CodeMirror-sizer">
<div>
<div class="CodeMirror-lines">
<div>
<div class="CodeMirror-code">
<div>
<div class="CodeMirror-gutter-wrapper">
<div class="CodeMirror-linenumber CodeMirror-gutter-elt" data-line-number="1"> </div>
</div>
<pre>CONTAINER ID     IMAGE   COMMAND    CREATED   STATUS    PORTS            NAMES</pre>
</div>
<div>
<pre>576c9e4cb65d sonarqube <span class="cm-string">" ./bin/run.sh"</span> <span class="cm-number">10</span> hours ago Up <span class="cm-number">10</span> hours <span class="cm-number">0</span>.0.0.0:9000-&gt;9000/tcp, <span class="cm-number">0</span>.0.0.0:9092-&gt;9092/tcp sonarqube</pre>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<p>When you see “ANALYSIS SUCCESSFUL,” you can head back over to the web GUI.</p>
<p><img decoding="async" class="fr-fin fr-dib" src="https://dzone.com/storage/temp/9063708-screen-shot-2018-05-08-at-100248-am.png" alt="Image title" width="828" /></p>
<p>This is the main SonarQube results screen. In this case, I&#8217;ve run analyses on two different batches of code—some Java/XML, and some PHP/JavaScript. Since the code is proprietary, I&#8217;ve redacted the names in this and the following screenshots. There&#8217;s not a lot of detail on this home screen, so let&#8217;s take a look at some other screens that show more actionable details.</p>
<p><img decoding="async" class="fr-fin fr-dib" src="https://dzone.com/storage/temp/9063710-screen-shot-2018-05-08-at-100302-am.png" alt="Image title" width="828" /></p>
<p>The code overview visualization. The closer a bubble&#8217;s color is to red, the more severe the worst bugs are. Bubble size indicates bug volume, and each bubble&#8217;s vertical position reflects the estimated time to address the bugs. Small green bubbles on the bottom edge are best. Hmmmm&#8230; Not looking good for this code.</p>
<p><img decoding="async" class="fr-fin fr-dib" src="https://dzone.com/storage/temp/9063715-screen-shot-2018-05-08-at-100317-am.png" alt="Image title" width="829" /></p>
<p>This diagram shows a high-level view of SonarSource&#8217;s definition of &#8220;maintainability.&#8221; Currently, SonarQube measures nine major metrics. The definitions for those metrics can be found here.</p>
<p>The size and color of the bubbles are a reflection of the code smells&#8217; long-term risks. The closer a bubble&#8217;s color is to red, the higher the ratio of technical debt is. Bubble size indicates code smell volume, and each bubble&#8217;s vertical position reflects the estimated time to address the code smells. Small green bubbles on the bottom edge are best. This diagram explains why the adjective &#8220;stinky&#8221; is appropriate for this code.</p>
<p><img decoding="async" class="fr-fin fr-dib" src="https://dzone.com/storage/temp/9063717-screen-shot-2018-05-08-at-100330-am.png" alt="Image title" width="830" /></p>
<p>This &#8220;Reliability Overview&#8221; is a major quality gate metric. It is a general measure of security, and also whether the measured code actually works as the developer intends it to.</p>
<p>SonarSource defines a quality gate as <em>a means to enforce a quality policy in your coding efforts.</em></p>
<p>It&#8217;s there to answer <u>one </u>question: can I deliver my project to production today or not?</p>
<p>SonarSource defines a default quality gate, the <em>Sonar_way</em>. Sonar_way is provided by SonarSource, is activated by default, and represents their view of the best way to implement code quality thresholds. The Sonar_way is a good starting point for determining metrics, but in the real world, it just makes sense to define this depending upon the project, and your organization&#8217;s risk appetite.</p>
<h3><strong>Step 5: Conclusion</strong></h3>
<p>This introduction is just that. There are other ways to run SonarQube both with and without Docker. There are so many ways to customize each particular scan that, really, the only solution is to RTFM. Hopefully, this introduction will get you going.  It will allow you to scan some code with SonarQube and visualize the results. Once you get to that point, you will be in a position to drill into the granularity of the SonarQube findings and to determine how best to work these findings into your current development workflows.</p>
<p>The post <a href="http://kostacipo.stream/this-is-the-perfect-spot-if-you-need-peace-and-quiet/">SonarQube Scanning in 15 Minutes</a> appeared first on <a href="http://kostacipo.stream">Tech Chronicles</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>http://kostacipo.stream/this-is-the-perfect-spot-if-you-need-peace-and-quiet/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
