{"id":1223,"date":"2023-09-28T22:34:22","date_gmt":"2023-09-28T17:04:22","guid":{"rendered":"https:\/\/www.openwriteup.com\/?page_id=1223"},"modified":"2025-01-31T09:30:04","modified_gmt":"2025-01-31T04:00:04","slug":"sonarqube-intergration","status":"publish","type":"page","link":"https:\/\/www.openwriteup.com\/?page_id=1223","title":{"rendered":"SonarQube intergration"},"content":{"rendered":"<p>step 1:<\/p>\n<p>Signup and SetUp &#8211; SonarQube Cloud account using GitHub Objective: In this lab, you will signup SonarQube Cloud account using GitHub Creating a SonarQube Cloud account using GitHub 1.<\/p>\n<p>Go to SonarQube cloud website<\/p>\n<p>https:\/\/www.sonarsource.com\/products\/sonarcloud\/<\/p>\n<p><a href=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/pic1.png\"><img fetchpriority=\"high\" decoding=\"async\" class=\"alignnone wp-image-1224\" src=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/pic1-300x194.png\" alt=\"\" width=\"503\" height=\"325\" srcset=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/pic1-300x194.png 300w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/pic1-700x453.png 700w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/pic1-768x497.png 768w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/pic1.png 1152w\" sizes=\"(max-width: 503px) 100vw, 503px\" \/><\/a><\/p>\n<p>Authorize sonalcloud<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/pic2.jpg\"><img decoding=\"async\" class=\"alignnone wp-image-1225\" src=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/pic2-300x178.jpg\" alt=\"\" width=\"467\" height=\"277\" srcset=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/pic2-300x178.jpg 300w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/pic2-700x416.jpg 700w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/pic2-768x456.jpg 768w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/pic2.jpg 1152w\" sizes=\"(max-width: 467px) 100vw, 467px\" \/><\/a><\/p>\n<p>3. go to github.com and fork below project<\/p>\n<p>https:\/\/github.com\/owtest23\/javaproj.git<\/p>\n<p><a href=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/gitfork.png\"><img decoding=\"async\" class=\"alignnone size-medium wp-image-1226\" src=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/gitfork-300x106.png\" alt=\"\" width=\"300\" height=\"106\" srcset=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/gitfork-300x106.png 300w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/gitfork-700x246.png 700w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/gitfork-768x270.png 768w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/gitfork-1536x540.png 1536w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/gitfork.png 1842w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/gitfork2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1227\" src=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/gitfork2-300x169.png\" alt=\"\" width=\"300\" height=\"169\" srcset=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/gitfork2-300x169.png 300w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/gitfork2-700x394.png 700w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/gitfork2-768x432.png 768w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/gitfork2.png 1152w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>4. Go to sonar cloud and import the orgnization<\/p>\n<p><a href=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/import.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1228\" src=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/import-300x169.png\" alt=\"\" width=\"300\" height=\"169\" srcset=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/import-300x169.png 300w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/import-700x394.png 700w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/import-768x432.png 768w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/import.png 1152w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>5. select repo<\/p>\n<p><a href=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/import2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1229\" src=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/import2-300x210.png\" alt=\"\" width=\"300\" height=\"210\" srcset=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/import2-300x210.png 300w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/import2-700x489.png 700w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/import2-768x537.png 768w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/import2.png 1152w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>6. install<\/p>\n<p><a href=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/import3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1230\" src=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/import3-300x169.png\" alt=\"\" width=\"300\" height=\"169\" srcset=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/import3-300x169.png 300w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/import3-700x394.png 700w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/import3-768x432.png 768w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/import3.png 1152w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>7. Note down the project key<\/p>\n<p><a href=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/import4.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1231\" src=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/import4-300x167.png\" alt=\"\" width=\"300\" height=\"167\" srcset=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/import4-300x167.png 300w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/import4-700x391.png 700w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/import4-768x429.png 768w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/import4.png 1243w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>8. create organization<\/p>\n<p><a href=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/import5.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1232\" src=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/import5-300x174.png\" alt=\"\" width=\"300\" height=\"174\" srcset=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/import5-300x174.png 300w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/import5-700x407.png 700w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/import5-768x447.png 768w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/import5.png 1152w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>9.anaylsis<\/p>\n<p><a href=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/an.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1233\" src=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/an-300x118.png\" alt=\"\" width=\"300\" height=\"118\" srcset=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/an-300x118.png 300w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/an-700x275.png 700w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/an-768x301.png 768w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/an-1536x602.png 1536w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/an.png 1660w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>. <a href=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/an2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1234\" src=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/an2-300x134.png\" alt=\"\" width=\"300\" height=\"134\" srcset=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/an2-300x134.png 300w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/an2-700x312.png 700w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/an2-768x342.png 768w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/an2-1536x684.png 1536w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/an2.png 1600w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/an3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1235\" src=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/an3-300x145.png\" alt=\"\" width=\"300\" height=\"145\" srcset=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/an3-300x145.png 300w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/an3-700x338.png 700w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/an3-768x370.png 768w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/an3-1536x741.png 1536w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/an3.png 1561w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>10. get token<\/p>\n<p><a href=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/an5.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1238\" src=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/an5-300x169.png\" alt=\"\" width=\"300\" height=\"169\" srcset=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/an5-300x169.png 300w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/an5-700x394.png 700w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/an5-768x432.png 768w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/an5.png 1152w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/an6.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1239\" src=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/an6-300x155.png\" alt=\"\" width=\"300\" height=\"155\" srcset=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/an6-300x155.png 300w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/an6-700x362.png 700w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/an6-768x397.png 768w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/an6.png 1261w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>generate the token and note it down<\/p>\n<p>12. Get the project key [click on my project&#8211;&gt;click on sample-java-sonar<\/p>\n<p><a href=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/proj1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-1240\" src=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/proj1-300x120.png\" alt=\"\" width=\"575\" height=\"230\" srcset=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/proj1-300x120.png 300w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/proj1-700x280.png 700w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/proj1-768x307.png 768w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/proj1-1536x614.png 1536w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/proj1.png 1621w\" sizes=\"(max-width: 575px) 100vw, 575px\" \/><\/a><\/p>\n<p>Left hand side select the icon<\/p>\n<p><a href=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/proj2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1241\" src=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/proj2-300x152.png\" alt=\"\" width=\"300\" height=\"152\" srcset=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/proj2-300x152.png 300w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/proj2-700x356.png 700w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/proj2-768x390.png 768w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/proj2-1536x780.png 1536w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/proj2.png 1650w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/proj3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1242\" src=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/proj3-300x169.png\" alt=\"\" width=\"300\" height=\"169\" srcset=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/proj3-300x169.png 300w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/proj3-700x394.png 700w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/proj3-768x432.png 768w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/proj3.png 1152w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a>&#8216;<\/p>\n<p>note down the project key<\/p>\n<p><a href=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/proj4.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1243\" src=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/proj4-300x169.png\" alt=\"\" width=\"300\" height=\"169\" srcset=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/proj4-300x169.png 300w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/proj4-700x394.png 700w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/proj4-768x432.png 768w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/proj4.png 1152w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>12. Prior to performing a Sonar scan through Jenkins, it is necessary to deactivate the automatic<br \/>\nanalysis option in the SonarQube web graphical user interface (GUI). a. Go to SonarQube Web GUI<br \/>\nand click on \u201cAdministration\u201d \u2192 \u201cAnalysis Method<\/p>\n<p><a href=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/proj5.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1244\" src=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/proj5-300x161.png\" alt=\"\" width=\"300\" height=\"161\" srcset=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/proj5-300x161.png 300w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/proj5-700x375.png 700w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/proj5-768x412.png 768w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/proj5-1536x824.png 1536w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/proj5.png 1563w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>13. setup quality gate<\/p>\n<p><a href=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/qual1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1245\" src=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/qual1-300x198.png\" alt=\"\" width=\"300\" height=\"198\" srcset=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/qual1-300x198.png 300w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/qual1-700x462.png 700w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/qual1-768x507.png 768w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/qual1.png 1152w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/qual2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1246\" src=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/qual2-300x134.png\" alt=\"\" width=\"300\" height=\"134\" srcset=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/qual2-300x134.png 300w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/qual2-700x312.png 700w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/qual2-768x343.png 768w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/qual2.png 1452w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>create new quality gate<\/p>\n<p><a href=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/qual3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1247\" src=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/qual3-300x120.png\" alt=\"\" width=\"300\" height=\"120\" srcset=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/qual3-300x120.png 300w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/qual3-700x281.png 700w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/qual3-768x308.png 768w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/qual3-1536x616.png 1536w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/qual3.png 1617w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Add condition<\/p>\n<p>&#8216;<a href=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/test1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1250\" src=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/test1-300x109.png\" alt=\"\" width=\"300\" height=\"109\" srcset=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/test1-300x109.png 300w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/test1-700x255.png 700w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/test1-768x280.png 768w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/test1-1536x559.png 1536w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/test1.png 1779w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/test2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1251\" src=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/test2-300x138.png\" alt=\"\" width=\"300\" height=\"138\" srcset=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/test2-300x138.png 300w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/test2-700x322.png 700w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/test2-768x353.png 768w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/test2-1536x707.png 1536w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/test2.png 1810w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>set default<\/p>\n<p><a href=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/test3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1252\" src=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/test3-300x152.png\" alt=\"\" width=\"300\" height=\"152\" srcset=\"https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/test3-300x152.png 300w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/test3-700x354.png 700w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/test3-768x388.png 768w, https:\/\/www.openwriteup.com\/wp-content\/uploads\/2023\/09\/test3.png 1487w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>modify the sudoers file in ubuntu<\/p>\n<pre>vi \/etc\/sudoers\r\n\r\njenkins ALL=(ALL) NOPASSWD: ALL<\/pre>\n<p>Write the pipeline<\/p>\n<pre>pipeline {\r\nagent any\r\n\r\nstages {\r\nstage('chckout scm') {\r\nsteps {\r\ncheckout scmGit(branches: [[name: '*\/master']], extensions: [], userRemoteConfigs: [[url: 'https:\/\/github.com\/hellokaton\/java11-examples.git']])\r\n}\r\n}\r\nstage('Compiling and Running Test Cases') {\r\nsteps {\r\nsh 'mvn clean'\r\nsh 'mvn compile'\r\nsh 'mvn test'\r\n}\r\n}\r\nstage('Generating a Cucumber Reports') {\r\nsteps {\r\nscript {\r\n\/\/ Run Cucumber tests and generate reports\r\nsh 'mvn verify'\r\n}\r\n}\r\n}\r\nstage('Creating Package') {\r\nsteps {\r\nsh 'mvn package'\r\n}\r\n}\r\nstage('adding genrerate report'){\r\nsteps {\r\nsh 'mvn verify'\r\n}\r\n}\r\nstage('Install sonarqube cli') {\r\nsteps {\r\n\/\/ Step to install SonarQube CLI\r\nsh 'sudo wget -O sonar-scanner.zip https:\/\/binaries.sonarsource.com\/Distribution\/sonar-scanner-cli\/sonar-scanner-cli-5.0.1.3006-linux.zip'\r\nsh 'sudo unzip -o -q sonar-scanner.zip'\r\nsh 'sudo rm -rf \/opt\/sonar-scanner'\r\nsh 'sudo mv --force sonar-scanner-5.0.1.3006-linux \/opt\/sonar-scanner'\r\nsh 'sudo sh -c \\'echo \"#\/bin\/bash \\nexport PATH=\\\\\\\"$PATH:\/opt\/sonar-scanner\/bin\\\\\\\"\" &gt;\/etc\/profile.d\/sonar-scanner.sh\\''\r\nsh 'sudo chmod +x \/opt\/sonar-scanner\/bin\/sonar-scanner'\r\nsh '. \/etc\/profile.d\/sonar-scanner.sh'\r\n}\r\n}\r\n\r\nstage('Analyzing Code Quality') {\r\nsteps {\r\n\/\/ Step to analyze code quality with SonarQube\r\nsh '\/opt\/sonar-scanner\/bin\/sonar-scanner -Dsonar.projectKey=owtest23_sample-java-sonar -Dsonar.organization=owtest23 -Dsonar.qualitygate.wait=true -Dsonar.qualitygate.timeout=300 -Dsonar.sources=src\/main\/java\/ -Dsonar.java.binaries=target\/classes -Dsonar.host.url=https:\/\/sonarcloud.io -Dsonar.login=65558d8b45ebd4758f3e8d49b8f3582f8707306'\r\n}\r\n}\r\n}\r\n}\r\n\r\n<\/pre>\n<p><strong>In case it is failing remove the stage due to permission issue, remove stage &#8220;Install sonarqube cli&#8221; and step. Perform all the step manually on ubuntu server<\/strong><\/p>\n<pre>wget -O sonar-scanner.zip https:\/\/binaries.sonarsource.com\/Distribution\/sonar-scanner-cli\/sonar-scanner-cli-5.0.1.3006-linux.zip\r\n\r\nunzip -o -q sonar-scanner.zip\r\n\r\nrm -rf \/opt\/sonar-scanner\r\n\r\nmv --force sonar-scanner-5.0.1.3006-linux \/opt\/sonar-scanner\r\n\r\nexport PATH=\"\/opt\/sonar-scanner\/bin\"\r\n\r\nchmod +x \/opt\/sonar-scanner\/bin\/sonar-scanner<\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Coverted same code in functional mode<\/strong><\/p>\n<p>&nbsp;<\/p>\n<pre>pipeline {\r\nagent any\r\nstages {\r\nstage('Checkout SCM') {\r\nsteps {\r\ncheckoutSCM()\r\n}\r\n}\r\n\r\nstage('Compiling and Running Test Cases') {\r\nsteps {\r\ncompileAndRunTests()\r\n}\r\n}\r\n\r\nstage('Generating a Cucumber Reports') {\r\nsteps {\r\ngenerateCucumberReports()\r\n}\r\n}\r\n\r\nstage('Creating Package') {\r\nsteps {\r\ncreatePackage()\r\n}\r\n}\r\n\r\nstage('Adding Generate Report') {\r\nsteps {\r\naddGenerateReport()\r\n}\r\n}\r\n\r\nstage('Install SonarQube CLI') {\r\nsteps {\r\ninstallSonarQubeCLI()\r\n}\r\n}\r\n\r\nstage('Analyzing Code Quality') {\r\nsteps {\r\nanalyzeCodeQuality()\r\n}\r\n}\r\n}\r\n}\r\n\r\ndef checkoutSCM() {\r\ncheckout scm: [$class: 'GitSCM', branches: [[name: '*\/master']], userRemoteConfigs: [[url: 'https:\/\/github.com\/hellokaton\/java11-examples.git']]]\r\n}\r\n\r\ndef compileAndRunTests() {\r\nsh 'mvn clean'\r\nsh 'mvn compile'\r\nsh 'mvn test'\r\n}\r\n\r\ndef generateCucumberReports() {\r\nscript {\r\nsh 'mvn verify'\r\n}\r\n}\r\n\r\ndef createPackage() {\r\nsh 'mvn package'\r\n}\r\n\r\ndef addGenerateReport() {\r\nsh 'mvn verify'\r\n}\r\n\r\ndef installSonarQubeCLI() {\r\nsh '''\r\nwget -O sonar-scanner.zip https:\/\/binaries.sonarsource.com\/Distribution\/sonar-scanner-cli\/sonar-scanner-cli-5.0.1.3006-linux.zip\r\nunzip -o -q sonar-scanner.zip\r\nrm -rf \/opt\/sonar-scanner\r\nsudo mv --force sonar-scanner-5.0.1.3006-linux \/opt\/sonar-scanner\r\nsudo sh -c 'echo \"#\/bin\/bash \\nexport PATH=\\\\\\\"$PATH:\/opt\/sonar-scanner\/bin\\\\\\\"\" &gt;\/etc\/profile.d\/sonar-scanner.sh'\r\nsudo chmod +x \/opt\/sonar-scanner\/bin\/sonar-scanner\r\n. \/etc\/profile.d\/sonar-scanner.sh\r\n'''\r\n}\r\n\r\ndef analyzeCodeQuality() {\r\nsh '''\r\n\/opt\/sonar-scanner\/bin\/sonar-scanner -Dsonar.projectKey=owtest23_sample-java-sonar \\\r\n-Dsonar.organization=owtest23 \\\r\n-Dsonar.qualitygate.wait=true \\\r\n-Dsonar.qualitygate.timeout=300 \\\r\n-Dsonar.sources=src\/main\/java\/ \\\r\n-Dsonar.java.binaries=target\/classes \\\r\n-Dsonar.host.url=https:\/\/sonarcloud.io \\\r\n-Dsonar.login=65558d8b45ebd4758f3e8d49b8f3582f8707306\r\n'''\r\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>step 1: Signup and SetUp &#8211; SonarQube Cloud account using GitHub Objective: In this lab, you will signup SonarQube Cloud account using GitHub Creating a SonarQube Cloud account using GitHub 1. Go to SonarQube cloud website https:\/\/www.sonarsource.com\/products\/sonarcloud\/ Authorize sonalcloud &nbsp; 3. go to github.com and fork below project https:\/\/github.com\/owtest23\/javaproj.git 4. Go to sonar cloud and import the orgnization 5. select repo 6. install 7. Note down the project key 8. create organization 9.anaylsis . &nbsp; 10. get token generate the token and note it down 12. Get the project key [click on my project&#8211;&gt;click on sample-java-sonar Left hand side select the icon &#8216; note down the project key &nbsp; 12. Prior to performing a Sonar scan through Jenkins, it is necessary to deactivate the automatic analysis option in the SonarQube web graphical user interface (GUI). a. Go to SonarQube Web GUI and click on \u201cAdministration\u201d \u2192 \u201cAnalysis Method 13. setup quality gate create new quality gate Add condition &#8216; set default modify the sudoers file in ubuntu vi \/etc\/sudoers jenkins ALL=(ALL) NOPASSWD: ALL Write the pipeline pipeline { agent any stages { stage(&#8216;chckout scm&#8217;) { steps { checkout scmGit(branches: [[name: &#8216;*\/master&#8217;]], extensions: [], userRemoteConfigs: [[url: &#8216;https:\/\/github.com\/hellokaton\/java11-examples.git&#8217;]]) } } stage(&#8216;Compiling and Running Test Cases&#8217;) { steps { sh &#8216;mvn clean&#8217; sh &#8216;mvn compile&#8217; sh &#8216;mvn test&#8217; } } stage(&#8216;Generating a Cucumber Reports&#8217;) { steps { script { \/\/ Run Cucumber tests and generate reports sh &#8216;mvn verify&#8217; } } } stage(&#8216;Creating Package&#8217;) { steps { sh &#8216;mvn package&#8217; } } stage(&#8216;adding genrerate report&#8217;){ steps { sh &#8216;mvn verify&#8217; } } stage(&#8216;Install sonarqube cli&#8217;) { steps { \/\/ Step to install SonarQube CLI sh &#8216;sudo wget -O sonar-scanner.zip https:\/\/binaries.sonarsource.com\/Distribution\/sonar-scanner-cli\/sonar-scanner-cli-5.0.1.3006-linux.zip&#8217; sh &#8216;sudo unzip -o -q sonar-scanner.zip&#8217; sh &#8216;sudo rm -rf \/opt\/sonar-scanner&#8217; sh &#8216;sudo mv &#8211;force sonar-scanner-5.0.1.3006-linux \/opt\/sonar-scanner&#8217; sh &#8216;sudo sh -c \\&#8217;echo &#8220;#\/bin\/bash \\nexport PATH=\\\\\\&#8221;$PATH:\/opt\/sonar-scanner\/bin\\\\\\&#8221;&#8221; &gt;\/etc\/profile.d\/sonar-scanner.sh\\&#8221; sh &#8216;sudo chmod +x \/opt\/sonar-scanner\/bin\/sonar-scanner&#8217; sh &#8216;. \/etc\/profile.d\/sonar-scanner.sh&#8217; } } stage(&#8216;Analyzing Code Quality&#8217;) { steps { \/\/ Step to analyze code quality with SonarQube sh &#8216;\/opt\/sonar-scanner\/bin\/sonar-scanner -Dsonar.projectKey=owtest23_sample-java-sonar -Dsonar.organization=owtest23 -Dsonar.qualitygate.wait=true -Dsonar.qualitygate.timeout=300 -Dsonar.sources=src\/main\/java\/ -Dsonar.java.binaries=target\/classes -Dsonar.host.url=https:\/\/sonarcloud.io -Dsonar.login=65558d8b45ebd4758f3e8d49b8f3582f8707306&#8217; } } } } In case it is failing remove the stage due to permission issue, remove stage &#8220;Install sonarqube cli&#8221; and step. Perform all the step manually on ubuntu server wget -O sonar-scanner.zip https:\/\/binaries.sonarsource.com\/Distribution\/sonar-scanner-cli\/sonar-scanner-cli-5.0.1.3006-linux.zip unzip -o -q sonar-scanner.zip rm -rf \/opt\/sonar-scanner mv &#8211;force sonar-scanner-5.0.1.3006-linux \/opt\/sonar-scanner export PATH=&#8221;\/opt\/sonar-scanner\/bin&#8221; chmod +x \/opt\/sonar-scanner\/bin\/sonar-scanner &nbsp; &nbsp; Coverted same code in functional mode &nbsp; pipeline { agent any stages { stage(&#8216;Checkout SCM&#8217;) { steps { checkoutSCM() } } stage(&#8216;Compiling and Running Test Cases&#8217;) { steps { compileAndRunTests() } } stage(&#8216;Generating a Cucumber Reports&#8217;) { steps { generateCucumberReports() } } stage(&#8216;Creating Package&#8217;) { steps { createPackage() } } stage(&#8216;Adding Generate Report&#8217;) { steps { addGenerateReport() } } stage(&#8216;Install SonarQube CLI&#8217;) { steps { installSonarQubeCLI() } } stage(&#8216;Analyzing Code Quality&#8217;) { steps { analyzeCodeQuality() } } } } def checkoutSCM() { checkout scm: [$class: &#8216;GitSCM&#8217;, branches: [[name: &#8216;*\/master&#8217;]], userRemoteConfigs: [[url: &#8216;https:\/\/github.com\/hellokaton\/java11-examples.git&#8217;]]] } def compileAndRunTests() { sh &#8216;mvn clean&#8217; sh &#8216;mvn compile&#8217; sh &#8216;mvn test&#8217; } def generateCucumberReports() { script { sh &#8216;mvn verify&#8217; } } def createPackage() { sh &#8216;mvn package&#8217; } def addGenerateReport() { sh &#8216;mvn verify&#8217; } def installSonarQubeCLI() { sh &#8221;&#8217; wget -O sonar-scanner.zip https:\/\/binaries.sonarsource.com\/Distribution\/sonar-scanner-cli\/sonar-scanner-cli-5.0.1.3006-linux.zip unzip -o -q sonar-scanner.zip rm -rf \/opt\/sonar-scanner sudo mv &#8211;force sonar-scanner-5.0.1.3006-linux \/opt\/sonar-scanner sudo sh -c &#8216;echo &#8220;#\/bin\/bash \\nexport PATH=\\\\\\&#8221;$PATH:\/opt\/sonar-scanner\/bin\\\\\\&#8221;&#8221; &gt;\/etc\/profile.d\/sonar-scanner.sh&#8217; sudo chmod +x \/opt\/sonar-scanner\/bin\/sonar-scanner . \/etc\/profile.d\/sonar-scanner.sh &#8221;&#8217; } def analyzeCodeQuality() { sh &#8221;&#8217; \/opt\/sonar-scanner\/bin\/sonar-scanner -Dsonar.projectKey=owtest23_sample-java-sonar \\ -Dsonar.organization=owtest23 \\ -Dsonar.qualitygate.wait=true \\ -Dsonar.qualitygate.timeout=300 \\ -Dsonar.sources=src\/main\/java\/ \\ -Dsonar.java.binaries=target\/classes \\ -Dsonar.host.url=https:\/\/sonarcloud.io \\ -Dsonar.login=65558d8b45ebd4758f3e8d49b8f3582f8707306 &#8221;&#8217; }<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-1223","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.openwriteup.com\/index.php?rest_route=\/wp\/v2\/pages\/1223","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.openwriteup.com\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.openwriteup.com\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.openwriteup.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.openwriteup.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1223"}],"version-history":[{"count":6,"href":"https:\/\/www.openwriteup.com\/index.php?rest_route=\/wp\/v2\/pages\/1223\/revisions"}],"predecessor-version":[{"id":1481,"href":"https:\/\/www.openwriteup.com\/index.php?rest_route=\/wp\/v2\/pages\/1223\/revisions\/1481"}],"wp:attachment":[{"href":"https:\/\/www.openwriteup.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1223"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}