- Install sonarqube on an instance ( alternatively, you can go to google cloud console -> marketplace -> search for sonarqune -> select sonarqube by Bitnami. This will prepare an instance with sonarqube along with database also installed. I preferred this, as it is a readymade product).
- Launch the sonarqube portal ( with the user id and password).
- Go to "Administration -> Security -> Users".
- Generate a token and note the token id.
- Now create a new instance ( in GCP / AWS /Azure as per your wish) and install Jenkins in the instance.
- Launch Jenkins with all recommended plugins.
- Click Manage Jenkins -> Manage Plugins
- Search for "SonarQube for Jenkins" plugin and install without restart
- Click Manage Jenkins -> Configure System
- Give as below:
11. Click Manage Jenkins -> Global Tool Configuration
12. Give as below:
13. Go to SSH of Jenkins instance and type the below commands
14. sudo su -
15. wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-3.3.0.1492-linux.zip
16. apt install unzip
17. unzip sonar-scanner-cli-3.3.0.1492-linux.zip
18. mv sonar-scanner-3.3.0.1492-linux /opt/sonar_scanner
19. cd /opt/sonar_scanner/conf
20. vi sonar-scanner.properties
21. change the line "sonar.host.url=*sonarqubeinstanceip*"
22. Now create a freestyle job in Jenkins. In "Add Build Step" select the value as EXECUTE SONARQUBE SCANNER
23. In Analysis properties, give the below details (text area):
sonar.login=token created in step 4
sonar.projectKey=GitHub respoistory namesonar.java.binaries=project/target
24. Build the job.
25. If the build is success, you can visit sonarqube portal and verify
No comments:
Post a Comment