diff --git a/scripts/pipelines/azure-devops/pipeline_generator.sh b/scripts/pipelines/azure-devops/pipeline_generator.sh index 10f2894d8..5423f3575 100755 --- a/scripts/pipelines/azure-devops/pipeline_generator.sh +++ b/scripts/pipelines/azure-devops/pipeline_generator.sh @@ -157,6 +157,8 @@ createNewBranch copyYAMLFile +add_jacoco_dependency + copyCommonScript type copyScript &> /dev/null && copyScript diff --git a/scripts/pipelines/common/pipeline_generator.lib b/scripts/pipelines/common/pipeline_generator.lib index 809eaeeed..e90cddb6b 100644 --- a/scripts/pipelines/common/pipeline_generator.lib +++ b/scripts/pipelines/common/pipeline_generator.lib @@ -268,6 +268,12 @@ function commitCommonFiles { # Add the YAML files. git add "$pipelinePath" -f + # Check if the pom.xml file exists before trying to add it. + if [ -f "pom.xml" ]; then + # Add the changes in the pom.xml file + git add "pom.xml" + fi + # Git commit and push it into the repository. # changing all files to be executable find "$pipelinePath" -type f -name '*.sh' -exec git update-index --chmod=+x {} \; @@ -292,3 +298,33 @@ function languageVersionVerification { exit 2 fi } +function add_jacoco_dependency { + if [[ "$language" == "quarkus"* ]]; then + echo -e "${green}Adding Jacoco plugin dependencies to pom.xml..." + echo -ne ${white} + + # Define the Jacoco plugin + jacoco_plugin=" +org.jacoco +jacoco-maven-plugin +0.8.7 + + + +prepare-agent + + + +report +prepare-package + +report + + + +" + + # Insert the Jacoco plugin into the pom.xml file + perl -i -pe "s||${jacoco_plugin}\n|g" "${localDirectory}/pom.xml" + fi +} diff --git a/scripts/pipelines/common/templates/build/quarkus-build.sh b/scripts/pipelines/common/templates/build/quarkus-build.sh index bf6bf918c..ff58535c9 100755 --- a/scripts/pipelines/common/templates/build/quarkus-build.sh +++ b/scripts/pipelines/common/templates/build/quarkus-build.sh @@ -1,2 +1,2 @@ #!/bin/bash -mvn package -B -Pnative \ No newline at end of file +mvn package -B -Pnative diff --git a/scripts/pipelines/common/templates/build/quarkus-jvm-build.sh b/scripts/pipelines/common/templates/build/quarkus-jvm-build.sh index 91082ed41..980361a45 100755 --- a/scripts/pipelines/common/templates/build/quarkus-jvm-build.sh +++ b/scripts/pipelines/common/templates/build/quarkus-jvm-build.sh @@ -1,2 +1,2 @@ #!/bin/bash -mvn package -B \ No newline at end of file +mvn package -B diff --git a/scripts/pipelines/common/templates/quality/quarkus-quality.sh.template b/scripts/pipelines/common/templates/quality/quarkus-quality.sh.template index 775be2a43..8d1826690 100755 --- a/scripts/pipelines/common/templates/quality/quarkus-quality.sh.template +++ b/scripts/pipelines/common/templates/quality/quarkus-quality.sh.template @@ -1,2 +1,2 @@ #!/bin/bash -mvn sonar:sonar -B -Dsonar.host.url="$SONAR_URL" -Dsonar.login="$SONAR_TOKEN" -Dsonar.java.binaries=$PROJECT_PATH/target/classes +mvn sonar:sonar -B -Dsonar.host.url="$SONAR_URL" -Dsonar.login="$SONAR_TOKEN" -Dsonar.java.binaries=$PROJECT_PATH/target/classes -Dsonar.coverage.jacoco.xmlReportPaths=$PROJECT_PATH/target/site/jacoco/jacoco.xml diff --git a/scripts/pipelines/common/templates/test/quarkus-jvm-test.sh b/scripts/pipelines/common/templates/test/quarkus-jvm-test.sh index 4e94d25ce..70a9269b9 100755 --- a/scripts/pipelines/common/templates/test/quarkus-jvm-test.sh +++ b/scripts/pipelines/common/templates/test/quarkus-jvm-test.sh @@ -1,2 +1,2 @@ #!/bin/bash -mvn test -B -Dmaven.install.skip=true +mvn test -B -Dmaven.install.skip=true -Djacoco.append=true -Dmaven.test.failure.ignore=true