diff --git a/note/README.md b/note/README.md index 94ec06a..35f6c12 100644 --- a/note/README.md +++ b/note/README.md @@ -357,6 +357,7 @@ ## [🔖 SonarQube实战](sonarqube/README.md) - [🔖 elasticSearch 安装](sonarqube/book/install.md) +- [Jenkins集成Sonarqube](sonarqube/book/jenkinsForSonarQube.md) ## [🔖 面试题总结](InterviewQuestions/JavaYouHuo面试题总结.md) diff --git a/note/sonarqube/README.md b/note/sonarqube/README.md index c15bc09..77c13f2 100644 --- a/note/sonarqube/README.md +++ b/note/sonarqube/README.md @@ -1,3 +1,4 @@ ## Sonarqube 实战 -###[Sonarqube 安装](book/install.md) \ No newline at end of file +###[Sonarqube 安装](book/install.md) +###[Jenkins集成Sonarqube](book/jenkinsForSonarQube.md) \ No newline at end of file diff --git a/note/sonarqube/book/jenkinsForSonarQube.md b/note/sonarqube/book/jenkinsForSonarQube.md new file mode 100644 index 0000000..ad06efe --- /dev/null +++ b/note/sonarqube/book/jenkinsForSonarQube.md @@ -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 + +``` + + org.sonarsource.scanner.maven + + + + + sonar + + true + + + + + + + + + + + +``` + + + +### 添加maven 插件 + +``` + + org.sonarsource.scanner.maven + sonar-maven-plugin + 3.3.0.603 + +``` + + + +## 部署 + +部署 的方式大家可以选择自己喜欢的方式 + +主要是执行如下命令 + +``` +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) \ No newline at end of file diff --git a/note/sonarqube/img/image-20220720135642149.png b/note/sonarqube/img/image-20220720135642149.png new file mode 100644 index 0000000..1b04cbf Binary files /dev/null and b/note/sonarqube/img/image-20220720135642149.png differ diff --git a/note/sonarqube/img/image-20220720135838080.png b/note/sonarqube/img/image-20220720135838080.png new file mode 100644 index 0000000..5b18809 Binary files /dev/null and b/note/sonarqube/img/image-20220720135838080.png differ diff --git a/note/sonarqube/img/image-20220720135933803.png b/note/sonarqube/img/image-20220720135933803.png new file mode 100644 index 0000000..df2c9e5 Binary files /dev/null and b/note/sonarqube/img/image-20220720135933803.png differ