Reputation: 203
I just concluded my GitHub integration with Jenkins so that every time I commit code to my GitHub repository, Jenkins automatically builds. Now I'm trying to integrate SonarCloud too but I haven't been successful. I'm not looking to integrate with a local SonarQube server, I really need SonarCloud for my team to check it every time Jenkins builds.
I'm not sure if I should analyse the project locally to achieve this or if I can analyse my Jenkins server or GitHub repository and get the result I want because I can't find any documentation.
Can anyone point me in the right direction?
Thank you!
Upvotes: 7
Views: 6464
Reputation: 16348
Sonarcloud is just a sonarqube server.
Just use sonar-scanner(the documentation for jenkins can be found here).
At first, you need to install the jenkins plugin for sonar-scanner.
After that, you open the configuration of sonar-scanner using Manage Jenkins > Configure System
.
Insert https://sonarcloud.io
under Server URL
and your sonar token(of sonarclound) under Server authentication token
Under Manage Jenkins > Configure System
, you should check Enable injection of SonarQube server configuration as build environment variables
and in Build Environment
in your job, you should enable Prepare SonarScanner environment
.
After you've done that, you can run sonar-scanner with $SONAR_MAVEN_GOAL
(if you are using maven), ./gradlew sonarqube
(if you are using gradle) or sonar-scanner
(if you use none of that).
Upvotes: 4