This commit is contained in:
GRUPOLKS\m.garcia 2025-03-31 13:49:24 +02:00
commit dae5f49210
2 changed files with 32 additions and 39 deletions

2
Jenkinsfile vendored
View file

@ -17,7 +17,7 @@ pipeline {
-v ./:/app \
-v "/home/jenkins/.m2":"/home/jenkins/.m2" \
-e JOB_ACTION="compile" \
-e MAVEN_CMD="clean verify sonar:sonar -Dsonar.host.url=$SONAR_HOST_URL -Dsonar.token=$SONAR_TOKEN -Dsonar.branch.name=$SONAR_BRANCH" \
-e MAVEN_CMD="clean verify sonar:sonar -Dsonar.host.url=$SONAR_HOST_URL -Dsonar.token=$SONAR_TOKEN -Dsonar.branch.name=$SONAR_BRANCH -Pcoverage" \
$BUILD_IMAGE
'''
}

69
pom.xml
View file

@ -250,44 +250,6 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.version}</version>
<executions>
<!-- Agente de JaCoCo para la instrumentación del código -->
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<!-- Generar el informe de cobertura en la fase "verify" para asegurar que se ejecuta después de los tests -->
<execution>
<id>report</id>
<phase>verify</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<outputEncoding>UTF-8</outputEncoding>
</configuration>
</execution>
<!-- Generar el informe en formato XML para SonarQube -->
<execution>
<id>report-aggregate</id>
<phase>verify</phase>
<goals>
<goal>report-aggregate</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/site/jacoco</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<!-- Spring Boot Actuator displays build-related information if a git.properties file is
present at the classpath -->
@ -477,5 +439,36 @@
</pluginManagement>
</build>
</profile>
<profile>
<id>coverage</id>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.7</version>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<goals>
<goal>report</goal>
</goals>
<configuration>
<formats>
<format>XML</format>
</formats>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>