---
# System prepended metadata

title: Jenkins Project(Java) & SonarQube
tags: [gradle, tomcat, jenkins]

---

---
title: 'Jenkins Project(Java) & SonarQube'
tags: jenkins,gradle,tomcat
description: Jenkins Project(Java) & SonarQube
---

# Jenkins Project(Java) & SonarQube

---

[TOC]

---

## 安裝 Jenkins SonarQube plugin

![](https://i.imgur.com/gFvUWcR.png)

安裝SonarQube Scanner for Jenkins


---

## 新增SonarQube憑證

先新增SonarQube的key
![](https://i.imgur.com/xFXCHXB.png)
![](https://i.imgur.com/Ang1G51.png)

Secret code請查看這篇文章：https://hackmd.io/htAzFkq9QmaHswPM8ndCgg
![](https://i.imgur.com/tTCN9Uv.png)


---

## 設定SonarQube server

![](https://i.imgur.com/8GqVv3A.png)
![](https://i.imgur.com/PTCf73P.png)


---

## 設定SonarQube scanner

![](https://i.imgur.com/q6XX88c.png)
![](https://i.imgur.com/rOhYklE.png)


---

## 設定Project SonarQube

Build Steps -> 新增建置步驟
![](https://i.imgur.com/4Es6YHx.png)
![](https://i.imgur.com/6zAUYTL.png)
![](https://i.imgur.com/L4y3VId.png)
``` properties
sonar.projectKey=demo
sonar.projectName=demo
sonar.projectVersion=0.1.0
sonar.sources=./src
sonar.language=java
sonar.sourceEncoding=UTF-8
sonar.java.binaries=./build/classes
sonar.login=sqp_d915e64920e667d656946e86fa726cf2ccbf13a7
```

---

## 參考連結

https://www.rickjiang.dev/blog/jenkins-with-sonarqube

---



