Incorporate Sonar into Jenkins
来源:互联网 发布:免费好用数据恢复软件 编辑:程序博客网 时间:2024/04/29 14:34
Sonar is a integrated code quality tool primarily for JAVA, but also support other languages such as javascript, C# etc. with plugin.
Jenkins is the most popular "Continous Integration" tool.
There're two way to incorporate Sonar as a build step into Jenkins job: Standalone sonar runner OR sonar-maven-plugin
(Here assumes you already installed Jenkins.)
Install Sonar
- Need to install a sonar instance, download from http://www.sonarsource.org/downloads
- start sonar service. E.g on a 64bit linux server, use:
$ <sonar-path>/bin/linux-x86-64/sonar.sh start
- the you can access http://127.0.0.1:9000 as Sonar URL. Note: By default the built-in H2 database does not support other server to access this sonar instance remotely by the IP/URL, unless you manually config it to use your own database instance like mysql.
- if you want to analyze javascript other than JAVA, download a sonar plugin: http://docs.codehaus.org/display/SONAR/JavaScript+Plugin
- download and install sonar-runner if you don't use sonar-maven-plugin: http://docs.codehaus.org/display/SONAR/Installing+and+Configuring+Sonar+Runner
- config sonar in Jenkins: http://127.0.0.1:8080/jenkins/configure
A javascript project with standalone runner
- add a post-build step of "Invoke Standalone Sonar Analysis"
- in the Project properties field
- assume you already use Cobertura running unit tests
# required metadatasonar.projectKey=<project.key>sonar.projectName=<projectName>sonar.projectVersion=1.0.0# path to source directories (required)sonar.sources=<path to source code># Uncomment this line to analyse a project which is not a java project.# The value of the property must be the key of the language.sonar.language=javascript
A JAVA project with standalone runner
- add a post-build step of "Invoke Standalone Sonar Analysis"
- in the Project properties field
- assume you already use Cobertura running unit tests, so to reuse the report
# required metadatasonar.projectKey=<project.key>sonar.projectName=<projectName>sonar.projectVersion=1.0.0# path to source directories (required)sonar.sources=<path to source code># Uncomment this line to analyse a project which is not a java project.# The value of the property must be the key of the language.sonar.language=javasonar.dynamicAnalysis=reuseReportssonar.surefire.reportsPath=<absolute path to TEST-*.xml>sonar.core.codeCoveragePlugin=coberturasonar.cobertura.reportPath=<absolut path to project>/cobertura/coverage.xml
A JAVA(maven) project with sonar-maven-plugin
- add below properties in pom.xml (assume using emma but not reuse the report. For other tool like jacoco, cobertura, see http://docs.codehaus.org/display/SONAR/Code+Coverage+by+Unit+Tests )
- add a post-build action of "Sonar"
<properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <sonar.language>java</sonar.language> <!-- Tells Sonar to reuse existing reports --> <sonar.dynamicAnalysis>true</sonar.dynamicAnalysis> <!-- Tells Sonar where the unit tests execution reports are --> <sonar.surefire.reportsPath>reports/junit</sonar.surefire.reportsPath> <!-- Tells Sonar to use Emma as the code coverage tool --> <sonar.core.codeCoveragePlugin>emma</sonar.core.codeCoveragePlugin> <!-- Tells Sonar where the unit tests code coverage reports are --> <sonar.emma.reportPath>reports/emma</sonar.emma.reportPath> </properties>
More Examples:
https://github.com/SonarSource/sonar-examples
- Incorporate Sonar into Jenkins
- Sonar Jenkins
- JENKINS插件之SONAR
- jenkins整合sonar
- sonar集成jenkins管理
- Jenkins 集成 Sonar
- Jenkins和Sonar集成
- jenkins 接入 Sonar
- maven+jenkins+sonar集成搭建
- maven+jenkins+sonar集成搭建
- jenkins sonar-scanner 安装测试
- Jenkins+Gitlab+Sonar代码检查平台搭建-Sonar
- 持续集成之jenkins+sonar(四)
- SONAR安装及与JENKINS的集成
- 配置sonar、jenkins进行持续审查
- 配置sonar、jenkins进行持续审查
- CentOS Jenkins + Sonar + Nexus 环境搭建
- 配置sonar、jenkins进行持续审查
- C语言中的双感叹号的作用
- Winform 进程之间通讯的几种方法
- cin、cin.get()、cin.getline()、getline()、gets()等函数的用法
- 8086汇编贪吃蛇(随机食物+速度递增)
- orthello 2D
- Incorporate Sonar into Jenkins
- 3天学习haskell---haskell第三天
- SAP EXCEL导入到内表
- 关于段错误
- android笔记之AndroidManifest.xml
- 回车和换行
- GREENPLUM优化建议
- 关于应用中过多的imageView和listView导致的不定时的oom(主要是bitmap 被VM buget 限制)和电子书的实现
- Linux ALSA声卡驱动之五:移动设备中的ALSA(ASoC)