forked from nagenn/SimplilearnAssist
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSonarQube.txt
55 lines (41 loc) · 2 KB
/
SonarQube.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
Check in /usr/lib/jvm if jdk-11 exists.
If it does, skip this:
Download Java 11
(sudo apt-get update
sudo apt-get install openjdk-11-jdk)
In Jenkins add a JDK for this path in Global Tool Config:
Manage Jenkins -> Global Tool Config -> add the new JDK under JDK installs
Download SonarQube (https://www.sonarqube.org/downloads/ - look for community edition)
Unzip once downloaded
Download Sonar Scanner (https://docs.sonarqube.org/latest/analysis/scan/sonarscanner/)
Unzip once downloaded
Edit Sonar-scanner.properties in conf directory of your sonar scanner unzip
Create a sonar-project.properties in your home directory - this can be an empty file
Install Sonar Scanner plug in on Jenkins
Start SonarQube server
- cd to sonarqube bin/linux..
- ./sonar.sh start or ./sonar.sh console to start
- localhost:9000 - login with admin/admin
- goto Administration -> Security -> Users ->admin- generate new token -> copy token
./sonar.sh stop (else, your lab system might hang)
Goto Manage Jenkins > Manage Credentials > System > Global Credentials > Add Credentials
Kind : Secret text
Secret : Paste SonarQube Authentication Token
Description : Provide a descriptive name
Click OK to add new credentials.
Manage Jenkins -> Configure System -> Add SonarQube
-> give a name /
-> URL: http://localhost:9000
-> authentication - choose the global credential you added above (SonarJ in my test)
Manage Jenkins -> Global Tool Config -> Add SonarQube Scanner
- give it a name
- SONAR-RUNNER-HOME: give it path to your sonar scanner unzip
Create FreeStyle job
- source: git (sample-java-maven-app)
- Build Trigger: None
- build step1: execute shell: javac '/home/labsuser/jenkins/workspace/SonarQ/src/main/java/com/mycompany/app/App.java' (command & path path to your code that needs compiling)
- build step2: Execute SonarQube Scanner
- jdk -> jdk_11
- Path to project properties: /home/labsuer (created in line 8 above)
Ensure SonarQube server is running: ./sonar.sh start
Jenkins job-> Build now