Add sonar analysis

This commit is contained in:
adrian.garcia 2025-03-24 13:23:46 +01:00
parent 2aa53f929d
commit 3234f1230f
2 changed files with 40 additions and 1 deletions

32
Jenkinsfile vendored Normal file
View file

@ -0,0 +1,32 @@
pipeline {
agent {
label 'zuvmljenson02'
}
environment {
BUILD_IMAGE = "registry.lksnext.com/devsecops/maven-java-17:2.0"
SONAR_TOKEN = credentials('sonar-analysis-token')
}
stages {
stage('Sonar') {
when {
environment name: 'JOB_ACTION', value: 'sonar'
}
steps {
script {
sh '''
docker run --rm \
-v ./:/app \
-v "/home/jenkins/.m2":"/home/jenkins/.m2" \
-e MAVEN_CMD="clean verify sonar:sonar -Dsonar.host.url=$SONAR_LKS_HOST_URL -Dsonar.token=$SONAR_TOKEN" \
$BUILD_IMAGE
'''
}
}
}
}
post {
always {
deleteDir()
}
}
}

View file

@ -38,6 +38,7 @@
<nohttp-checkstyle.version>0.0.11</nohttp-checkstyle.version> <nohttp-checkstyle.version>0.0.11</nohttp-checkstyle.version>
<spring-format.version>0.0.43</spring-format.version> <spring-format.version>0.0.43</spring-format.version>
<sonar.projectKey>spring-petclinic</sonar.projectKey>
</properties> </properties>
<dependencies> <dependencies>
@ -287,6 +288,12 @@
<artifactId>cyclonedx-maven-plugin</artifactId> <artifactId>cyclonedx-maven-plugin</artifactId>
</plugin> </plugin>
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.9.1.2184</version>
</plugin>
</plugins> </plugins>
</build> </build>
<licenses> <licenses>