docker run -d --name sonar -p 9000:9000 sonarqube:lts-community
comminty branch - https://hub.docker.com/r/mc1arke/sonarqube-with-community-branch-plugin
Configuration - configuration of sq Security - user management Projects - Project management System - to check the status Marketplace - to install plugins and all
Quality profile
we can add and modify the rules anfter taking a copy
jacoco is using for java
url and usr/password required for access any
install sonaqube scanner plugin in jenkins
Administration --> security --> user --> token -->
Manage Jenkins --> Credentials --> System --> Global credentials (unrestricted) --> New credentials
kind : secret text Scope : Global (Jenkins, nodes, items, all child items, etc) Secret : Token ID: sonar-token Description : sonar-token
pipeline {
agent any
tools {
maven 'M3'
}
environment {
SCANNER_HOME = tool 'sonar-scanner'
}
stages {
stage('git') {
steps {
echo 'git checkout'
git branch: 'main', url: 'https://github.com/pythonkid2/Boardgame.git'
}
}
stage('unit test') {
steps {
echo 'mvn test'
sh 'mvn test'
}
}
stage('sonar analysis') {
steps {
withSonarQubeEnv('sonar-server') {
sh '''$SCANNER_HOME/bin/sonar-scanner -Dsonar.projectName=BoardGame -Dsonar.projectKey=BoardGame \
-Dsonar.java.binaries=target'''
}
}
}
stage('package') {
steps {
echo 'mvn package'
sh 'mvn package'
}
}
}
}
+++
community branch pluggin -
add -
-Dsonar.branch.name=branch-name
mc1arke/sonarqube-community-branch-plugin https://github.com/mc1arke/sonarqube-community-branch-plugin
https://hub.docker.com/r/mc1arke/sonarqube-with-community-branch-plugin
- Access the SonarQube container:
docker exec -it 2710 /bin/bash
-
Navigate to the
extensions/pluginsdirectory:cd /opt/sonarqube/extensions/plugins -
Download the SonarQube Community Branch Plugin:
wget https://github.com/mc1arke/sonarqube-community-branch-plugin/releases/download/1.16.0/sonarqube-community-branch-plugin-1.16.0.jar
exit and restart the container docker restart
plugin version matrix - to check the supported versions
if quality gate is passed then only it will proceed with pipeline`
Administration --> Configuration --> Webhooks --> Create
http://18.220.71.120:8080/sonarqube-webhook/
go to jenkins
stage('Quality gate') {
steps {
script {
waitForQualityGate abortPipeline: false, credentialsId: 'sonar-cred'
}
}






