Execute this docker-compose.yml configuration file to start SonarQube, a PostgreSQL database and Jenkins CI.
docker compose up
Restart the containers (after plugin upgrade or install for example).
docker compose restart sonarqube
Analyse a project with Maven:
mvn sonar:sonar \
-Dsonar.host.url=http://localhost:9000 \
-Dsonar.login=<sonar-analysis-token>
Command to stop and remove compose environment:
docker compose down --rmi local -v --remove-orphans
Sample project with Jenkinsfile:
node {
// Mark the code checkout 'stage'....
stage 'Checkout'
checkout scm
stage 'Configure'
env.PATH = "${tool 'Maven 3'}/bin:${env.PATH}"
// Mark the code build 'stage'....
stage('Build') {
// Run the maven build
sh “mvn clean verify -Dmaven.test.failure.ignore=true”
}
stage('SonarQube analysis') {
withSonarQubeEnv('Sonarqube') {
sh 'mvn sonar:sonar'
}
}
}
- Plugins
- ...