gabrie-allaigre / sonar-gitlab-plugin

Add to each commit GitLab in a global commentary on the new anomalies added by this commit and add comment lines of modified files
GNU Lesser General Public License v3.0
713 stars 208 forks source link

Why is Sonar GitLab Plugin not sending analyze results to gitlab as a comments while using default templates? #114

Open Veranicus opened 6 years ago

Veranicus commented 6 years ago

Hi there, I currently have a jenkins job that is triggered when push or commit is made within a gitlab project with the use of a configurated webhooks. Everything works fine and projects are analyzed when they're supposed to with SonarQube scanner for maven method, the problem is I want to then push SonarQube to analyze results to a given project in form of global or inline comments. So I have installed on my sonarQube server Sonar Gitlab plugin. Problem is it's not making those comments with results.

I have used default templates for global and inline comments as are stated in plugin documentation.

I haven't added any other configuration in connection with this except the ones I have stated in my post, thanks.

I'm linking images to each part of my gitlab configuration in SonarQube Server:

SonarQubeConfig1 - The gitlab name is direct https link directly to a repository : config1

SonarQubeConfig2 - FreeMarker syntax configuration in global and inline comments is directly from the default template which you can find in Sonar Gitlab Plugin documentation:

config2

SonarQubeConfig3 config3

Thank you.

gabrie-allaigre commented 6 years ago

Hi, Have you a log and command line ? Thanks

Veranicus commented 6 years ago

Hi there, I'm doing everything inside Jenkins with SonarQube scanner for Jenkins plugin installed and then on a server where is SonarQube installed in options as I have posted in images before.

Veranicus commented 6 years ago

I don't know what do you mean by log and a command line exactly ?

gabrie-allaigre commented 6 years ago

log for mvn sonar:sonar ....

Veranicus commented 6 years ago

I don't know where to find a log for mvn sonar:sonar. The way I have it configured is that I have a job in jenkins that is analysing my repositories on gitlab with sonarqube, this job is triggered by a webhooks for push and merge events. It works perfectly, now I want to put analyse results in form of a comments to a gitlab, so I have your plugin installed, everything configured like inside of your documentation. I have already posted my gitlab config to you, now I have also enabled and added CI pipeline to my gitlab repo, it looks excatly as in your documentation:

ciconfg

Now it started several times, hovewer not in a times it should have, not after push or merge event but right after I added the pipeline and then it was just pending all the time and was saying it needs gitlab runner to start the pipeline... I don't know what I'm doing wrong. The only thing I want is after the job in jenkins is triggered, it analyse the project and after this analysis it posts the outcome of analysis to a gitlab, thank you.

gabrie-allaigre commented 6 years ago

Hi, If use gitlab-ci, log in pipeline job.

Veranicus commented 6 years ago

Can I somehow do it without using gitlab-ci ? Perhaps somehow only with a jenkins ? I don't want to be using another slave for gitlab-ci. Thank you.

Veranicus commented 6 years ago

And by the way, do I need gitlab enterprise edition to do anything with this plugin ?

gabrie-allaigre commented 6 years ago

I use gitlab ce and sonarqube ce only. Plugin work. Plugin work with gitlab-ci, jenkins and others

Veranicus commented 6 years ago

Could you please post me some screenshots of how exactly can you configure it with gitlab ce and sonarqube ce only ? Thank you very much.

nikhilsobti commented 6 years ago

Hi Guys, Further to this discussion. I am only using Gitlabs for Repo management and SonarQube for result analysis. Can someone guide me how do I send/see these results on Gitlabs (without using much different tools). Is there a proper procedure to configure seeing Sonarqube analysis results? Will if I add/delete/push a file on Gitlabs, will it then run Sonarqube analysis on its own and results will follow? Thanks, Nikhil

qhh0205 commented 5 years ago

Hi, all, @gabrie-allaigre The same issue to me, i have read the documentation, but I didn't find out how to integrate it with jenkins. Is there an example use with Jenkins pipeline? Now i use sonar with jenkins pipeline code as following(dont know how to use this plugin with jenkins、mvn sonar scaner):

 withSonarQubeEnv('SonarQube') {
           withCredentials([string(credentialsId: 'sonarToken', variable: 'sonarToken')]) {
             sh "cd ${buildScriptPath} && mvn sonar:sonar -Dsonar.host.url=$sonarHost -Dsonar.login=$sonarToken"
           }
  }