How to integrate gitlab repo (develop branch) in sonarqube - jenkins

I am very new to the sonarqube.
I am running sonarqube via docker and I want to get my GitLab projects reflected there.
kindly guide.
Thanks in advance.

You will need to invoke sonarscanner from you Gitlab CI and point to your Sonarqube instance (either cloud or on-premise).
You can start with the SonarQube manual, which has a snippet of gitlab-ci.yml that you can drop into your pipeline.

Related

how could i publish sonarqube report in jenkins? using the sonarqube portlet

I have configured sonarqube for one of my projects, but now i want to publish the sonarqube details in my jenkins dashboard. what could be the best possible way to do that?
I'm not sure that there is a straight forward way of getting "all" the data from sonar on to your Jenkins dashboard but can actually get a sonar badge and Quality gate info by using the Sonar plugin for Jenkins.
https://docs.sonarqube.org/latest/analysis/scan/sonarscanner-for-jenkins/?q=cache:Tbhy8757pK4J:https://docs.sonarqube.org/latest/analysis/scan/sonarscanner-for-jenkins/+&cd=1&hl=en&ct=clnk&gl=us
First of all, you need to deploy sonarqube on your local machine, ones it is done, then copy the URL of your sonarqube server, I am assuming, you have deployed sonarqube server on port 9090, once this done, log in to the sonarqube server and then create a project and then generate a token for that project:
Once these above configuration is done, just hit below maven command to generate sonarqube report on the sonarqube server:
mvn sonar:sonar -Dsonar.projectKey=[projectName] -Dsonar.host.url=http://localhost:9090 -Dsonar.login=[tokenId]
Below is the screenshot, this is how your reports on the sonarqube will looks like:

How can use SonarScanner from Jenkins while running on a different server (than Sonar)?

I use Jenkins for Continuous Integration, and I plan to add SonarQube to its tasks. I know it is possible to run SonarQube server and database remotely from the scanner, thanks to the documentation.
I tried to install sonarqube and sonarscanner plugins in Jenkins, setting up a slave connected to the server hosting sonarqube and sonarscanner, but Jenkins can't trigger a scan.
I also don't understand how Sonar would get the code ? Is Jenkins supposed to send it all to the server ?
Or do I have to manage the pulling from the repository on the server hosting Sonar ?
You're correct, the scanner must be on the build machine.

How to integrate SonarCloud with GitHub and Jenkins

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!
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).

Pipeline by using Jenkins with private SVN repository

I am trying to implement CI/CD pipeline for my microservice oriented project by using Kubernetes and Jenkins. I am using my code repository on my on-premise server. I created one SVN repository on my server.
I am interested to know, can I use my private SVN code repository with Jenkins?
The reason for my doubt is because every example is showing the creation of pipeline with Jenkins and GitHub project.
You can use the shell command in your pipeline. So you are free to use SVN with Jenkins:
https://tortoisesvn.net/docs/nightly/TortoiseSVN_en/tsvn-cli-main.html
Some info there:
Run bash command on jenkins pipeline

Build fails on VSTS with error connect ETIMEDOUT 52.173.242.81:8080, on jenkins build is successfully executed

I'm trying out DevOps with VSTS, Docker and Java and I'm stuck with failing builds PFA screenshots of the same.
VSTS build failing while Queue Jenkins job task
Job is successfully executed on Jenkins and .War file is also produced.
This has been setup on Azure following document
https://github.com/msdevno/hol-oss-devops
Another approach is to have the commit to VSTS trigger the build in Jenkins. Then have Jenkins trigger the release in VSTS. Setting up CI/CD with the TFS Plugin for Jenkins This would not require using VSTS for build.
I was able to resolve the above issue.
My guess worked out correct.
Changing the Public IP from Dynamic to Static caused this issue.
Looked into Jenkins configuration(Manange Jenkins > Configure System > Jenkins Location > Jenkins URL) This was containing dynamic IP and now I've changed it to new static IP and voila it works fine. Build Succeeds and status updated on VSTS as well :)
Thanks for sparing your time in looking to my issue #Starain-MSFT & #Donovan

Resources