Gitlab integration with SonarQube

Adi picture Adi · Mar 21, 2017 · Viewed 46.3k times · Source

I am pretty new to Development community and specifically to DevOps practices , as a part of project we are trying to integrate SonarQube with Gitlab , did some R& D on SonarQube and Git CI ( Continuous Integration ) and look like plugin is released for Github and SonarQube whereas not for Gitlab.

How realistic is it to configure GitLab with SonarQube for inspecting code quality for every pull request and what will be the best practice to integrate these two piece.

Thanks

Answer

Joergi picture Joergi · May 17, 2017

you don't really need a plugin. make something like this in your .gitlab-ci.yml

stages: 
- build 
build_master:
  image: maven
  stage: build
  artifacts:
    paths:
    - target/*.jar
  script:
  - mvn package sonar:sonar -Dsonar.host.url=https://sonar.yourdomain.tld/ 
  only:
  - master

and every master push will be tested! (this is for a Java project...)