You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/examples/jenkins/sonarqube-jenkins/README.md
+9-28Lines changed: 9 additions & 28 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
description: Tutorial on how to push code scanning results from Jenkins pipeline to SonarQube and how to display SonarQube data in Jenkins.
3
3
---
4
4
5
-
# Jenkins and SonarQube
5
+
# Integrating Jenkins and SonarQube
6
6
7
7
This example uses the same Jenkins configuration as the [Jenkins with access to hosts Docker engine](../jenkins-host-docker/) example. If you did any configuration in [jenkins-host-docker](../jenkins-host-docker/) directory, sync the project names with `-p`/`--project-name` option or `COMPOSE_PROJECT_NAME` environment variable to use the same volumes. For example:
To get started with SonarQube, access the [Web UI](http://localhost:9000) and login with `admin:admin` credentials. Create a access token in [My account > Security](http://localhost:9000/account/security/) and store the token. Use this access token to authenticate to SonarQube from CI instead of the username and password combination.
@@ -43,33 +49,8 @@ First, install SonarQube Scanner plugin to your Jenkins instance through [Manage
43
49
44
50
After the SonarQube server is configured to Jenkins, sonar-scanner can be executed in a stage that uses the same [sonarsource/sonar-scanner-cli](https://hub.docker.com/r/sonarsource/sonar-scanner-cli) Docker image that was used in the previous step as well. This can be done with a stage level Docker agent:
45
51
46
-
```Groovy
47
-
stage('Analyze') {
48
-
agent {
49
-
docker {
50
-
image 'sonarsource/sonar-scanner-cli'
51
-
// In order to be able to use http://sonarqube:9000 we need to be in the
52
-
// same network as Jenkins and SonarQube are in.
53
-
args '--net jenkins_default'
54
-
// To guarantee that the workspace contains the sources pulled in previous
55
-
// stage, we need to use the pipeline level workspace.
56
-
reuseNode true
57
-
}
58
-
}
59
-
steps {
60
-
// The parameter must match the name you gave for the SonarQube server when
61
-
// configuring it.
62
-
withSonarQubeEnv('Sonar') {
63
-
// Here, job name is used as the project key and current workspace as the
See [Jenkinsfile](./Jenkinsfile) for a example of a complete pipeline. If you try to execute this example pipeline replace `${GIT_URL}` with the URL to your git repository of choice.
0 commit comments