{"id":1444,"date":"2016-11-09T20:52:13","date_gmt":"2016-11-09T12:52:13","guid":{"rendered":"http:\/\/coderbee.net\/?p=1444"},"modified":"2016-11-09T20:52:13","modified_gmt":"2016-11-09T12:52:13","slug":"sonarqube-%e9%85%8d%e7%bd%ae","status":"publish","type":"post","link":"https:\/\/coderbee.net\/index.php\/tool\/20161109\/1444","title":{"rendered":"SonarQube \u914d\u7f6e"},"content":{"rendered":"<h1>1. \u5b89\u88c5 SonarQube \u548c\u6570\u636e\u5e93<\/h1>\n<p>\u4e0b\u8f7d\u6700\u65b0\u7684 sonarqube-6.1\u3001MySQL 5.7.X\u3002<\/p>\n<p>\u521b\u5efa\u6570\u636e\u5e93\uff1a<\/p>\n<pre><code class=\"sql\">CREATE DATABASE `SonarQube` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;\n\nCREATE USER SonarQube IDENTIFIED BY 'SonarQube#123';\n\nGRANT ALL PRIVILEGES ON SonarQube.* TO SonarQube;\nflush privileges;\n<\/code><\/pre>\n<p>\u914d\u7f6e sonarqube \u670d\u52a1\u5668\uff0c $sonarqube_home\/conf\/sonar.properties \u6587\u4ef6\uff1a<\/p>\n<pre><code class=\"properties\">sonar.jdbc.username=SonarQube\nsonar.jdbc.password=SonarQube#123\n\nsonar.jdbc.url=jdbc:mysql:\/\/localhost:3306\/SonarQube?useUnicode=true&amp;characterEncoding=utf8&amp;rewriteBatchedStatements=true&amp;useConfigs=maxPerformance\n\nsonar.web.host=0.0.0.0\nsonar.web.port=9000\n<\/code><\/pre>\n<p><!--more--><\/p>\n<h1>2. \u5206\u6790 Maven \u5de5\u7a0b<\/h1>\n<p>\u5728 <code>$M2_HOME\/conf\/settings.xml<\/code> \u914d\u7f6e\u5982\u4e0b\uff1a<\/p>\n<pre><code class=\"xml\">&lt;profile&gt;\n    &lt;id&gt;sonar&lt;\/id&gt;\n    &lt;activation&gt;\n        &lt;activeByDefault&gt;true&lt;\/activeByDefault&gt;\n    &lt;\/activation&gt;\n    &lt;properties&gt;\n        &lt;sonar.jdbc.url&gt;jdbc:mysql:\/\/localhost:3306\/SonarQube&lt;\/sonar.jdbc.url&gt;\n        &lt;sonar.jdbc.driver&gt;com.mysql.jdbc.Driver&lt;\/sonar.jdbc.driver&gt;\n        &lt;sonar.jdbc.username&gt;SonarQube&lt;\/sonar.jdbc.username&gt;\n        &lt;sonar.jdbc.password&gt;SonarQube#123&lt;\/sonar.jdbc.password&gt;\n        &lt;sonar.host.url&gt;http:\/\/localhost:9000&lt;\/sonar.host.url&gt;\n    &lt;\/properties&gt;\n&lt;\/profile&gt;\n<\/code><\/pre>\n<p>\u6ce8\u610f\u8fd9\u91cc\u7684\u6570\u636e\u5e93\u914d\u7f6e\u548c sonar.host \u914d\u7f6e\u5fc5\u987b\u4e0e\u524d\u9762\u7684\u4e00\u81f4\u3002<\/p>\n<p>\u7136\u540e\u5c31\u53ef\u4ee5\u901a\u8fc7 mvn sonar:sonar \u6765\u6267\u884c\u4ee3\u7801\u5206\u6790\uff0c\u5e76\u5c06\u7ed3\u679c\u4fdd\u5b58\u5728 Sonar \u6570\u636e\u5e93\u4e2d\u3002<\/p>\n<p>\u4e5f\u53ef\u4ee5\u53c2\u8003\uff1a <a href=\"http:\/\/docs.sonarqube.org\/display\/SCAN\/Analyzing+with+SonarQube+Scanner+for+Maven\">http:\/\/docs.sonarqube.org\/display\/SCAN\/Analyzing+with+SonarQube+Scanner+for+Maven<\/a><\/p>\n<h1>\u5206\u6790 Ant \u9879\u76ee<\/h1>\n<p>\u53c2\u8003\uff1a <a href=\"http:\/\/docs.sonarqube.org\/display\/SCAN\/Analyzing+with+SonarQube+Scanner+for+Ant\">http:\/\/docs.sonarqube.org\/display\/SCAN\/Analyzing+with+SonarQube+Scanner+for+Ant<\/a><\/p>\n<p>\u9996\u5148\u4e0b\u8f7d <a href=\"https:\/\/sonarsource.bintray.com\/Distribution\/sonarqube-ant-task\/sonarqube-ant-task-2.5.jar\">SonarQube Scanner for Ant 2.5<\/a> \uff0c<\/p>\n<pre><code class=\"xml\">&lt;project name=\"My Project\" default=\"all\" basedir=\".\" xmlns:sonar=\"antlib:org.sonar.ant\"&gt;\n...\n\n&lt;!-- Define the SonarQube global properties (the most usual way is to pass these properties via the command line) --&gt;\n&lt;property name=\"sonar.host.url\" value=\"http:\/\/localhost:9000\" \/&gt;\n\n...\n\n&lt;!-- Define the SonarQube project properties --&gt;\n&lt;property name=\"sonar.projectKey\" value=\"org.codehaus.sonar:example-java-ant\" \/&gt;\n&lt;property name=\"sonar.projectName\" value=\"Simple Java Project analyzed with the SonarQube Ant Task\" \/&gt;\n&lt;property name=\"sonar.projectVersion\" value=\"1.0\" \/&gt;\n&lt;property name=\"sonar.sources\" value=\"src\" \/&gt;\n&lt;property name=\"sonar.java.binaries\" value=\"build\" \/&gt;\n&lt;property name=\"sonar.java.libraries\" value=\"lib\/*.jar\" \/&gt;\n...\n\n&lt;!-- Define the SonarQube target --&gt;\n&lt;target name=\"sonar\"&gt;\n    &lt;taskdef uri=\"antlib:org.sonar.ant\" resource=\"org\/sonar\/ant\/antlib.xml\"&gt;\n        &lt;!-- Update the following line, or put the \"sonarqube-ant-task-*.jar\" file in your \"$HOME\/.ant\/lib\" folder --&gt;\n        &lt;classpath path=\"path\/to\/sonar\/ant\/task\/lib\/sonarqube-ant-task-*.jar\" \/&gt;\n    &lt;\/taskdef&gt;\n\n    &lt;!-- Execute the SonarQube analysis --&gt;\n    &lt;sonar:sonar \/&gt;\n&lt;\/target&gt;\n<\/code><\/pre>\n<p>\u7136\u540e\u6267\u884c <code>ant sonar<\/code> \u5373\u53ef\u3002<\/p>\n<p>\u591a\u6a21\u5757\u9879\u76ee\u914d\u7f6e\uff1a<\/p>\n<pre><code class=\"xml\">&lt;!-- Set modules IDs --&gt;\n&lt;property name=\"sonar.modules\" value=\"module-one,module-two\"\/&gt;\n\n&lt;!-- For modules, properties are inherited from the parent. They can be overridden as shown below: --&gt;\n&lt;property name=\"module-one.sonar.projectName\" value=\"Module One\" \/&gt;\n&lt;property name=\"module-one.sonar.sources\" value=\"sources\/java\" \/&gt;\n&lt;property name=\"module-one.sonar.binaries\" value=\"target\" \/&gt;\n&lt;!-- Default module base directory is &lt;curent_directory&gt;\/&lt;module_ID&gt;. It can be overridden if necessary --&gt;\n&lt;property name=\"module-one.sonar.projectBaseDir\" value=\"Module 1\" \/&gt;  \n<\/code><\/pre>\n<h1>\u4e0e Jekins \u96c6\u6210<\/h1>\n<p>\u5bf9\u4e8e Ant \u9879\u76ee\uff0c\u5728 Jekins \u4e0b\u53ef\u80fd\u4f1a\u78b0\u5230 <code>SVNAuthenticationException: svn: E170001<\/code> \u9519\u8bef\uff0c\u5728 SonarQube \u670d\u52a1\u5668\u4e0a\u8bbe\u7f6e <code>\u914d\u7f6e &gt;  \u901a\u7528\u914d\u7f6e  &gt;  SCM<\/code>\uff0c \u628a <code>Disable the SCM Sensor<\/code> \u6253\u5f00\u3002<\/p>\n<hr\/>\n<p>\u6b22\u8fce\u5173\u6ce8\u6211\u7684\u5fae\u4fe1\u516c\u4f17\u53f7: <strong>coderbee\u7b14\u8bb0<\/strong>\uff0c\u53ef\u4ee5\u66f4\u53ca\u65f6\u56de\u590d\u4f60\u7684\u8ba8\u8bba\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"258\" height=\"258\" src=\"https:\/\/coderbee.net\/wp-content\/uploads\/2019\/01\/coderbee-note.jpg\" class=\"alignnone size-full wp-image-1707\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. \u5b89\u88c5 SonarQube \u548c\u6570\u636e\u5e93 \u4e0b\u8f7d\u6700\u65b0\u7684 sonarqube-6.1 &hellip; <a href=\"https:\/\/coderbee.net\/index.php\/tool\/20161109\/1444\">\u7ee7\u7eed\u9605\u8bfb <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[116],"tags":[],"_links":{"self":[{"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/posts\/1444"}],"collection":[{"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/comments?post=1444"}],"version-history":[{"count":1,"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/posts\/1444\/revisions"}],"predecessor-version":[{"id":1445,"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/posts\/1444\/revisions\/1445"}],"wp:attachment":[{"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/media?parent=1444"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/categories?post=1444"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/tags?post=1444"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}