Skip to content

Commit

Permalink
add Jenkins集成Sonarqube 🆕 📖
Browse files Browse the repository at this point in the history
  • Loading branch information
yanghaiji committed Aug 8, 2022
1 parent e14d2ca commit 320aeee
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 1 deletion.
1 change: 1 addition & 0 deletions note/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@

## [🔖 SonarQube实战](sonarqube/README.md)
- [🔖 elasticSearch 安装](sonarqube/book/install.md)
- [Jenkins集成Sonarqube](sonarqube/book/jenkinsForSonarQube.md)


## [🔖 面试题总结](InterviewQuestions/JavaYouHuo面试题总结.md)
Expand Down
3 changes: 2 additions & 1 deletion note/sonarqube/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
## Sonarqube 实战

###[Sonarqube 安装](book/install.md)
###[Sonarqube 安装](book/install.md)
###[Jenkins集成Sonarqube](book/jenkinsForSonarQube.md)
80 changes: 80 additions & 0 deletions note/sonarqube/book/jenkinsForSonarQube.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Jenkins集成Sonarqube

> 本是以Maven项目为示例进行的集成演练
## Jenkins 安装插件

- [SonarQube Scanner](https://plugins.jenkins.io/sonar/)

- [Sonar Quality Gates](https://plugins.jenkins.io/sonar-quality-gates/)

## 配置 SonarQube Scanner

![image-20220720135642149](../img/image-20220720135642149.png)



## 配置SonarQube servers

![image-20220720135838080](../img/image-20220720135838080.png)

这里需要添加 token,我们可以去SonarQube 页面生成

![image-20220720135933803](../img/image-20220720135933803.png)



## Maven 配置

### 修改 setting.xml

```
<pluginGroups>
<pluginGroup>org.sonarsource.scanner.maven</pluginGroup>
</pluginGroups>
<profile>
<id>sonar</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<sonar.host.url>
<!-- 配置 Sonar Host地址,默认:http://localhost:9000 -->
</sonar.host.url>
<sonar.login>
<!-- 配置 填写生成的tokne -->
</sonar.login>
</properties>
</profile>
```



### 添加maven 插件

```
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.3.0.603</version>
</plugin>
```



## 部署

部署 的方式大家可以选择自己喜欢的方式

主要是执行如下命令

```
mvn clean -DskipTests=true install org.sonarsource.scanner.maven:sonar-maven-plugin:3.3.0.603:sonar
```

这样会将artifactId 标签作为项目名称,展现在 sonarqube上

![image-20220720140858393](C:\Users\ZZ0DFI672\AppData\Roaming\Typora\typora-user-images\image-20220720140858393.png)
Binary file added note/sonarqube/img/image-20220720135642149.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added note/sonarqube/img/image-20220720135838080.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added note/sonarqube/img/image-20220720135933803.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 320aeee

Please sign in to comment.