{"id":857,"date":"2022-03-17T19:58:33","date_gmt":"2022-03-17T11:58:33","guid":{"rendered":"https:\/\/www.buyao007.icu\/?p=857"},"modified":"2022-03-17T22:37:58","modified_gmt":"2022-03-17T14:37:58","slug":"7-%e4%bb%a3%e7%a0%81%e8%87%aa%e5%8a%a8%e4%b8%8a%e7%ba%bf-jenkins%e9%9b%86%e6%88%90sonarqube%e8%b4%a8%e6%a3%80","status":"publish","type":"post","link":"https:\/\/www.buyao007.icu\/?p=857","title":{"rendered":"7.\u4ee3\u7801\u81ea\u52a8\u4e0a\u7ebf\u2014Jenkins\u96c6\u6210SonarQube\u8d28\u68c0"},"content":{"rendered":"\n<p>\u5b59\u5bcc\u9633\uff0c \u6c5f\u6e56\u4eba\u79f0\u6ca1\u4eba\u79f0\u3002\u591a\u5e74\u4e92\u8054\u7f51\u8fd0\u7ef4\u5de5\u4f5c\u7ecf\u9a8c\uff0c\u66fe\u8d1f\u8d23\u8fc7\u5b59\u5e03\u65af\u5927\u89c4\u6a21\u96c6\u7fa4\u67b6\u6784\u81ea\u52a8\u5316\u8fd0\u7ef4\u7ba1\u7406\u5de5\u4f5c\u3002\u64c5\u957fWeb\u96c6\u7fa4\u67b6\u6784\u4e0e\u81ea\u52a8\u5316\u8fd0\u7ef4\uff0c\u66fe\u8d1f\u8d23\u56fd\u5185\u67d0\u5927\u578b\u535a\u5ba2\u7f51\u7ad9\u8fd0\u7ef4\u5de5\u4f5c\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"toc_0\">1.SonarQube\u57fa\u672c\u6982\u8ff0<\/h2>\n\n\n\n<p><strong><em>1.\u4ec0\u4e48\u662fSonarQube<\/em><\/strong><\/p>\n\n\n\n<p>SonarQube\u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u4ee3\u7801\u8d28\u91cf\u7ba1\u7406\u7cfb\u7edf\uff0c\u7528\u4e8e\u68c0\u6d4b\u4ee3\u7801\u4e2d\u7684\u9519\u8bef\u3001\u6f0f\u6d1e\u3002\u5b83\u53ef\u4ee5\u4e0eJenkins\u96c6\u6210\uff0c\u8ba9\u6211\u4eec\u80fd\u81ea\u52a8\u5316\u8fdb\u884c\u4ee3\u7801\u8d28\u91cf\u626b\u63cf<\/p>\n\n\n\n<p><strong><em>2.\u4f7f\u7528SonarQube\u524d\u63d0<\/em><\/strong><\/p>\n\n\n\n<p>1.SonarQube\u57fa\u4e8eJava\u5f00\u53d1\uff0c\u6240\u4ee5\u9700\u8981\u5b89\u88c5Open JDK8\u7248\u672c\u3002<br>2.SonarQube\u9700\u8981\u4f9d\u8d56MySQL\u6570\u636e\u5e93\uff0c\u81f3\u5c115.6\u7248\u672c\u4ee5\u4e0a\u3002<br>3.SonarQube\u7684\u5c0f\u578b\u5b9e\u4f8b\u81f3\u5c11\u9700\u89814GB\u5185\u5b58\uff0c\u5982\u679c\u662f\u5927\u578b\u5b9e\u4f8b\u9700\u898116GB<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"toc_0\">2.SonarQube\u670d\u52a1\u5b89\u88c5<\/h2>\n\n\n\n<p>Sonarqube7.9\u4ee5\u4e0a\u7248\u672c\u5df2\u7ecf\u4e0d\u652f\u6301mysql\u6570\u636e\u5e93\u4e86<\/p>\n\n\n\n<p><strong><em>1.\u5b89\u88c5Sonarqube\u4f9d\u8d56\u5de5\u5177<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@sonarqube ~]# yum install git java-11 unzip wget -y\n&#91;root@sonarqube ~]# cat \/etc\/yum.repos.d\/psql.repo\n&#91;psql]\nname=psql repo\nbaseurl=https:\/\/mirror.tuna.tsinghua.edu.cn\/postgresql\/repos\/yum\/9.6\/redhat\/rhel-7.9-x86_64\/\nenabled=1\ngpgcheck=0\n&#91;root@sonarqube ~]# yum install -y  postgresql96-server\n##\u521d\u59cb\u5316\u6570\u636e\u5e93\n&#91;root@sonarqube ~]# \/usr\/pgsql-9.6\/bin\/postgresql96-setup initdb\n<\/code><\/pre>\n\n\n\n<p><strong><em>2.\u542f\u52a8\u6570\u636e\u5e93\uff0c\u7136\u540e\u4e3a\u6570\u636e\u5e93\u914d\u7f6e\u5bc6\u7801\u3002\u6700\u540e\u521b\u5efa\u4e00\u4e2asonar\u5e93<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@sonarqube ~]#  su - postgres\n&#91;postgres@sonarqube ~]$ psql \npsql (9.6.22)\nType \"help\" for help.\npostgres=# CREATE USER sonar WITH PASSWORD 'sfy';\nCREATE ROLE\npostgres=# CREATE DATABASE sonar OWNER sonar;\nCREATE DATABASE\npostgres=# GRANT ALL PRIVILEGES ON DATABASE sonar TO sonar;\nGRANT\npostgres=# exit\npostgres-# \\q\n###\u4fee\u6539\u4e00\u4e0b\u6570\u636e\u5e93\u7684\u914d\u7f6e\u6587\u4ef6\n&#91;root@sonarqube ~]# grep -Ev \"#|^$\" \/var\/lib\/pgsql\/9.6\/data\/pg_hba.conf\nlocal   all             all                                     md5\nhost    all             all             127.0.0.1\/32            md5\nhost    all             all             ::1\/128                 ident\n&#91;root@sonarqube ~]$ systemctl start postgresql-9.6.service\n&#91;root@sonarqube ~]$ systemctl enable postgresql-9.6.service\n\n<\/code><\/pre>\n\n\n\n<p><strong><em>3.\u4e0b\u8f7dsonarqube\uff0c\u5e76\u5b89\u88c5\u89e3\u538b\u81f3\/usr\/local<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@sonarqube ~]# wget https:\/\/binaries.sonarsource.com\/Distribution\/sonarqube\/sonarqube-8.9.2.46101.zip\n&#91;root@sonarqube ~]# unzip sonarqube-8.9.2.46101.zip -d \/usr\/local\/\n&#91;root@sonarqube ~]# useradd sonar\n&#91;root@sonarqube ~]# chown -R sonar.sonar \/usr\/local\/sonarqube-8.9.2.46101\/\n&#91;root@sonarqube ~]# ln -s \/usr\/local\/sonarqube-8.9.2.46101\/ \/usr\/local\/sonarqube\n<\/code><\/pre>\n\n\n\n<p><strong><em>4.\u4fee\u6539sonarqube\u8fde\u63a5\u6570\u636e\u5e93\u914d\u7f6e\u6587\u4ef6<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@sonarqube ~]# vim \/usr\/local\/sonarqube\/conf\/sonar.properties\nsonar.jdbc.username=sonar\nsonar.jdbc.password=sfy\nsonar.jdbc.url=jdbc:postgresql:\/\/localhost\/sonar\n<\/code><\/pre>\n\n\n\n<p><strong><em>5. \u5728Linux \u4e0a\u8fd0\u884c\uff0c\u5fc5\u987b\u786e\u4fdd\u4ee5\u4e0b\u914d\u7f6e<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>vm.max_map_count\u5927\u4e8e\u6216\u7b49\u4e8e524288\nfs.file-max\u5927\u4e8e\u6216\u7b49\u4e8e131072\n\u8fd0\u884c\u58f0\u7eb3Qube\u7684\u7528\u6237\u81f3\u5c11\u53ef\u4ee5\u6253\u5f00131072\u6587\u4ef6\u63cf\u8ff0\u7b26\n\u8fd0\u884c\u58f0\u7eb3Qube\u7684\u7528\u6237\u53ef\u4ee5\u6253\u5f00\u81f3\u5c118192\u7ebf\u7a0b\n\u60a8\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u67e5\u770b\u503c\uff1a\nsysctl vm.max_map_count\nsysctl fs.file-max\nulimit -n\nulimit -u\n\u60a8\u53ef\u4ee5\u901a\u8fc7\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u52a8\u6001\u5730\u4e3a\u5f53\u524d\u4f1a\u8bdd\u8bbe\u7f6e\u5b83\u4eec\uff0c\u5982\u4e0b\u6240\u5217\u547d\u4ee4\u4e3a\uff1aroot\nsysctl -w vm.max_map_count=524288\nsysctl -w fs.file-max=131072\nulimit -n 131072\nulimit -u 8192\n\u5982\u679c\u8fd0\u884csonarQube\u7684\u7528\u6237\u6ca1\u6709\u6743\u9650\u81f3\u5c11\u62e5\u6709131072\u4e2a\u6253\u5f00\u7684\u63cf\u8ff0\u7b26\uff0c\u5219\u60a8\u5fc5\u987b\u5728\/etc\/security\/limits.d\/99-sonarqube.conf(\u6216         \/etc\/security\/limits.conf)\u63d2\u5165:sonarqube\nsonarqube   -   nofile   131072\nsonarqube   -   nproc    8192\n\u5982\u679c\u60a8\u6b63\u5728\u4f7f\u7528systemd sonarQube\uff0c\u60a8\u5fc5\u987b\u5728&#91;service]\u4e2d\u6307\u5b9a\u5355\u4f4d\u6587\u4ef6\u4e2d\u7684\u8fd9\u4e9b\u9650\u5236\uff1asystemd\n&#91;Service]\n...\nLimitNOFILE=131072\nLimitNPROC=8192\n...\n<\/code><\/pre>\n\n\n\n<p><strong><em>6.\u542f\u52a8sonarqube\u670d\u52a1(\u7531\u4e8ees\u5fc5\u987b\u666e\u901a\u7528\u6237\u542f\u52a8\uff0c\u6240\u4ee5\u4e0d\u80fd\u4f7f\u7528root\u7528\u6237\uff0c\u5426\u5219\u542f\u52a8\u5931\u8d25)<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@sonarqube ~]# su - sonar -c \"\/usr\/local\/sonarqube\/bin\/linux-x86-64\/sonar.sh start\"<\/code><\/pre>\n\n\n\n<p><strong><em>7.\u8bbf\u95eesonarqube\u754c\u9762\u8bbf\u95ee \u901a\u8fc7\u6d4f\u89c8\u5668\u8bbf\u95eehttp:\/\/hostname:9000<\/em><\/strong><\/p>\n\n\n\n<p><em>\u70b9\u51fb\u767b\u5f55--&gt;\u8f93\u5165\u7528\u6237\u540d\uff1aadmin \u7528\u6237\u5bc6\u7801\uff1aadmin<\/em><\/p>\n\n\n\n<p>\u4e2d\u6587\u6c49\u5316\uff0c\u70b9\u51fb\u914d\u7f6e-\u5e94\u7528\u5e02\u573a-\u641c\u7d22chinese-\u70b9\u51fb\u5b89\u88c5<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"865\" height=\"432\" src=\"https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/03\/image-62.png\" alt=\"\" class=\"wp-image-860\" srcset=\"https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/03\/image-62.png 865w, https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/03\/image-62-300x150.png 300w, https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/03\/image-62-768x384.png 768w\" sizes=\"(max-width: 865px) 100vw, 865px\" \/><figcaption>\u5b89\u88c5\u540e\u91cd\u542f\u670d\u52a1\u5c31\u53d8\u4e3a\u4e2d\u6587\u4e86<\/figcaption><\/figure>\n\n\n\n<p>\u767b\u5f55\u540e\u914d\u7f6etocken\u4ee4\u724c<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"865\" height=\"430\" src=\"https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/03\/image-63.png\" alt=\"\" class=\"wp-image-861\" srcset=\"https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/03\/image-63.png 865w, https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/03\/image-63-300x149.png 300w, https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/03\/image-63-768x382.png 768w\" sizes=\"(max-width: 865px) 100vw, 865px\" \/><figcaption>dd0a20e1cbc40b08a71af1766550f1c838ee66fe<\/figcaption><\/figure>\n\n\n\n<p>\u70b9\u51fb\u521b\u5efa\u9879\u76ee-\u521b\u5efa\u4ee4\u724c\uff0c\u4f7f\u7528\u5df2\u6709\u4ee4\u724c\uff0c\u5c06\u521a\u624d\u7684\u4ee4\u724c\u590d\u5236\u8fdb\u6765<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"865\" height=\"340\" src=\"https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/03\/image-64.png\" alt=\"\" class=\"wp-image-862\" srcset=\"https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/03\/image-64.png 865w, https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/03\/image-64-300x118.png 300w, https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/03\/image-64-768x302.png 768w\" sizes=\"(max-width: 865px) 100vw, 865px\" \/><figcaption>\u70b9\u51fb\u7ee7\u7eed<\/figcaption><\/figure>\n\n\n\n<p>\u7ee7\u7eed\u9009\u62e9\u5206\u6790\u4f60\u7684\u9879\u76ee-\u9009\u62e9\u6784\u5efa\u6280\u672f<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"865\" height=\"379\" src=\"https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/03\/image-65.png\" alt=\"\" class=\"wp-image-863\" srcset=\"https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/03\/image-65.png 865w, https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/03\/image-65-300x131.png 300w, https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/03\/image-65-768x336.png 768w\" sizes=\"(max-width: 865px) 100vw, 865px\" \/><figcaption>\u5982\u679c\u8981\u5206\u6790\u5176\u4ed6\u8bed\u8a00\uff0c\u9700\u8981\u914d\u7f6e\u53c2\u8003\u5982\u4e0b\u5b98\u65b9\u8fde\u63a5https:\/\/docs.sonarqube.org\/latest\/analysis\/scan\/sonarscanner\/<\/figcaption><\/figure>\n\n\n\n<p>\u70b9\u51fb\u9879\u76ee\u540d\u79f0\u540e\u53ef\u4ee5\u770b\u5230\u8d28\u68c0\u7ed3\u679c<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"865\" height=\"432\" src=\"https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/03\/image-66.png\" alt=\"\" class=\"wp-image-864\" srcset=\"https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/03\/image-66.png 865w, https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/03\/image-66-300x150.png 300w, https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/03\/image-66-768x384.png 768w\" sizes=\"(max-width: 865px) 100vw, 865px\" \/><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>##\u8fd8\u9700\u8981\u5b89\u88c5\u4e00\u4e0b\u5982\u4e0b\u63d2\u4ef6\nsonar-java-plugin-5.6.0.15032.jar\nsonar-scm-git-plugin-1.3.0.869.jar\nsonar-csharp-plugin-7.3.0.5690.jar\nsonar-javascript-plugin-4.0.9.5862.jar\nsonar-scm-svn-plugin-1.6.0.869.jar\nsonar-css-plugin-1.1.1.1010.jar\nsonar-i10n-zh-plugin-1.20.jar\nsonar-typescript-plugin-1.9.0.3766.jar\nsonar-flex-plugin-2.5.1.1831.jar\nsonar-php-plugin-3.0.0.4537.jar\nonar-xml-plugin-2.0.1.2020.jar\nsonar-html-plugin-3.0.1.1444.jar\nsonar-python-plugin-1.9.0.2010.jar\n<\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b59\u5bcc\u9633\uff0c \u6c5f\u6e56\u4eba\u79f0\u6ca1\u4eba\u79f0\u3002\u591a\u5e74\u4e92\u8054\u7f51\u8fd0\u7ef4\u5de5\u4f5c\u7ecf\u9a8c\uff0c\u66fe\u8d1f\u8d23\u8fc7\u5b59\u5e03\u65af\u5927\u89c4\u6a21\u96c6\u7fa4\u67b6\u6784\u81ea\u52a8\u5316\u8fd0\u7ef4\u7ba1\u7406\u5de5\u4f5c\u3002\u64c5\u957fWeb\u96c6 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":246,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[],"_links":{"self":[{"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=\/wp\/v2\/posts\/857"}],"collection":[{"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=857"}],"version-history":[{"count":4,"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=\/wp\/v2\/posts\/857\/revisions"}],"predecessor-version":[{"id":867,"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=\/wp\/v2\/posts\/857\/revisions\/867"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=\/wp\/v2\/media\/246"}],"wp:attachment":[{"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=857"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=857"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=857"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}