Integrate sonarqube with jenkins using docker and pipelines

Posted By : Jatin Gupta | 31-Jul-2019

SonarQube (in the past Sonar) is an open source stage created by SonarSource for consistent assessment of code quality to perform programmed surveys with static examination of code to identify bugs, code scents, and security vulnerabilities on 20+ programming dialects. SonarQube offers gives an account of copied code, coding gauges, unit tests, code scope, code multifaceted nature, remarks, bugs, and security vulnerabilities.

 

SonarQube can record measurements history and gives development charts. SonarQube's furnishes completely computerized examination and mix with Maven, Ant, Gradle, MSBuild and persistent combination devices (Atlassian Bamboo, Jenkins, Hudson, and so on.)

 

Sonarqube can be integrated with jenkins so as to set it as a quality check for the build to be passed onto deployment.

 

Let us start,

First let us run jenkins, sonarqube server and postgres ( database for sonarqube ) using docker-compose.


version: '2'
services:
  jenkins:
    image: jenkins-docker
    name: jenkins-master
    restart: always
    volumes:
      - /path/to/dir:/var/jenkins_home
      - /var/run/docker.sock:/var/run/docker.sock
    ports:
      - "8080:8080"
      - "50000:50000"

  postgres:
    image: postgres:9.6
    name: postgres
    environment:
      POSTGRES_USER: sonar
      POSTGRES_PASSWORD: sonar
    volumes:
      - /var/postgres-data:/var/lib/postgresql/data

  sonarqube:
    image: sonarqube:lts
    name: sonarqube-server
    ports:
      - "9000:9000"
      - "9092:9092"
    environment:
      SONARQUBE_JDBC_USERNAME: sonar
      SONARQUBE_JDBC_PASSWORD: sonar
      SONARQUBE_JDBC_URL: "jdbc:postgresql://postgres:5432/sonar"
    depends_on:
      - postgres

 

About Author

Author Image
Jatin Gupta

Jatin is a DevOps trainee. He ha deep interest in python and cloud technologies. He likes to read about science/history and fiction, listening to music and explore new places.

Request for Proposal

Name is required

Comment is required

Sending message..