From cdc6d62d9fbfb76656ca30ee4a060a92d9a461ed Mon Sep 17 00:00:00 2001 From: victordrose Date: Thu, 14 Dec 2023 09:58:54 +0100 Subject: [PATCH 01/26] added function to the script that adds plugin to pom.xml as well as the lines in the test and quality scripts --- .../pipelines/azure-devops/pipeline_generator.sh | 15 +++++++++++++++ .../templates/quality/quarkus-quality.sh.template | 2 +- .../common/templates/test/quarkus-jvm-test.sh | 2 +- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/scripts/pipelines/azure-devops/pipeline_generator.sh b/scripts/pipelines/azure-devops/pipeline_generator.sh index 10f2894d8..86c02151e 100755 --- a/scripts/pipelines/azure-devops/pipeline_generator.sh +++ b/scripts/pipelines/azure-devops/pipeline_generator.sh @@ -138,6 +138,19 @@ function createPR { fi } +function add_jacoco_dependency { + if [[ $language == "quarkus"* ]] + then + echo "Adding JaCoCo dependency to pom.xml..." + sed -i '/<\/dependencies>/i\ + \ + org.jacoco\ + jacoco-maven-plugin\ + jacoco.3.2.0\ + ' $localDirectory/pom.xml + fi +} + obtainHangarPath # Load common functions @@ -161,6 +174,8 @@ copyCommonScript type copyScript &> /dev/null && copyScript +add_jacoco_dependency + commitCommonFiles type commitFiles &> /dev/null && commitFiles diff --git a/scripts/pipelines/common/templates/quality/quarkus-quality.sh.template b/scripts/pipelines/common/templates/quality/quarkus-quality.sh.template index 775be2a43..7ace273ce 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=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 From 5e3b855a5216ffc968e49b30fb4aeff2a30f30c6 Mon Sep 17 00:00:00 2001 From: victordrose Date: Thu, 14 Dec 2023 11:49:23 +0100 Subject: [PATCH 02/26] =?UTF-8?q?cambiada=20funci=C3=B3n=20add=5Fjacoco=5F?= =?UTF-8?q?dependencies?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../azure-devops/pipeline_generator.sh | 32 +++++++++++++++---- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/scripts/pipelines/azure-devops/pipeline_generator.sh b/scripts/pipelines/azure-devops/pipeline_generator.sh index 86c02151e..845d8334e 100755 --- a/scripts/pipelines/azure-devops/pipeline_generator.sh +++ b/scripts/pipelines/azure-devops/pipeline_generator.sh @@ -142,12 +142,32 @@ function add_jacoco_dependency { if [[ $language == "quarkus"* ]] then echo "Adding JaCoCo dependency to pom.xml..." - sed -i '/<\/dependencies>/i\ - \ - org.jacoco\ - jacoco-maven-plugin\ - jacoco.3.2.0\ - ' $localDirectory/pom.xml + python3 -c +import xml.etree.ElementTree as ET + +# Parse the pom.xml file +tree = ET.parse('$localDirectory/pom.xml') +root = tree.getroot() + +# Define the namespace +namespaces = {'xmlns': 'http://maven.apache.org/POM/4.0.0'} +ET.register_namespace('', namespaces['xmlns']) + +# Find the element +dependencies = root.find('xmlns:dependencies', namespaces) + +# Create the JaCoCo dependency element +dependency = ET.SubElement(dependencies, 'dependency') +groupId = ET.SubElement(dependency, 'groupId') +groupId.text = 'org.jacoco' +artifactId = ET.SubElement(dependency, 'artifactId') +artifactId.text = 'jacoco-maven-plugin' +version = ET.SubElement(dependency, 'version') +version.text = '3.2.0' # Replace with the actual version of JaCoCo + +# Write the modified XML back to the pom.xml file +tree.write('$localDirectory/pom.xml', encoding='utf-8', xml_declaration=True) + fi } From 1411091fac1519ac2ca8d98bee9ff6cd714c18dd Mon Sep 17 00:00:00 2001 From: victordrose Date: Thu, 14 Dec 2023 12:09:40 +0100 Subject: [PATCH 03/26] .. --- scripts/pipelines/azure-devops/pipeline_generator.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/scripts/pipelines/azure-devops/pipeline_generator.sh b/scripts/pipelines/azure-devops/pipeline_generator.sh index 845d8334e..30f505ef1 100755 --- a/scripts/pipelines/azure-devops/pipeline_generator.sh +++ b/scripts/pipelines/azure-devops/pipeline_generator.sh @@ -142,11 +142,12 @@ function add_jacoco_dependency { if [[ $language == "quarkus"* ]] then echo "Adding JaCoCo dependency to pom.xml..." - python3 -c + python3 - < Date: Thu, 14 Dec 2023 12:11:44 +0100 Subject: [PATCH 04/26] . --- scripts/pipelines/azure-devops/pipeline_generator.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/pipelines/azure-devops/pipeline_generator.sh b/scripts/pipelines/azure-devops/pipeline_generator.sh index 30f505ef1..a9265c208 100755 --- a/scripts/pipelines/azure-devops/pipeline_generator.sh +++ b/scripts/pipelines/azure-devops/pipeline_generator.sh @@ -147,7 +147,7 @@ import xml.etree.ElementTree as ET import os # Parse the pom.xml file -tree = ET.parse(os.environ['PROJECT_PATH'] + '/pom.xml') +tree = ET.parse(os.environ['${localDirectory}'] + '/pom.xml') root = tree.getroot() # Define the namespace @@ -164,10 +164,10 @@ groupId.text = 'org.jacoco' artifactId = ET.SubElement(dependency, 'artifactId') artifactId.text = 'jacoco-maven-plugin' version = ET.SubElement(dependency, 'version') -version.text = '0.8.7' # Replace with the actual version of JaCoCo +version.text = '3.2.0' # Replace with the actual version of JaCoCo # Write the modified XML back to the pom.xml file -tree.write(os.environ['PROJECT_PATH'] + '/pom.xml', encoding='utf-8', xml_declaration=True) +tree.write(os.environ['${localDirectory}'] + '/pom.xml', encoding='utf-8', xml_declaration=True) EOF fi } From 915585bb5722239839b29987d8bf7778e233457c Mon Sep 17 00:00:00 2001 From: victordrose Date: Thu, 14 Dec 2023 12:20:06 +0100 Subject: [PATCH 05/26] - --- scripts/pipelines/azure-devops/pipeline_generator.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/scripts/pipelines/azure-devops/pipeline_generator.sh b/scripts/pipelines/azure-devops/pipeline_generator.sh index a9265c208..3e066d357 100755 --- a/scripts/pipelines/azure-devops/pipeline_generator.sh +++ b/scripts/pipelines/azure-devops/pipeline_generator.sh @@ -142,12 +142,11 @@ function add_jacoco_dependency { if [[ $language == "quarkus"* ]] then echo "Adding JaCoCo dependency to pom.xml..." - python3 - < Date: Thu, 14 Dec 2023 13:57:01 +0100 Subject: [PATCH 06/26] commented function --- .../azure-devops/pipeline_generator.sh | 66 +++++++++---------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/scripts/pipelines/azure-devops/pipeline_generator.sh b/scripts/pipelines/azure-devops/pipeline_generator.sh index 3e066d357..a4a0bdaf4 100755 --- a/scripts/pipelines/azure-devops/pipeline_generator.sh +++ b/scripts/pipelines/azure-devops/pipeline_generator.sh @@ -138,38 +138,38 @@ function createPR { fi } -function add_jacoco_dependency { - if [[ $language == "quarkus"* ]] - then - echo "Adding JaCoCo dependency to pom.xml..." - python3 -c " -import xml.etree.ElementTree as ET - -# Parse the pom.xml file -tree = ET.parse('$localDirectory/pom.xml') -root = tree.getroot() - -# Define the namespace -namespaces = {'xmlns': 'http://maven.apache.org/POM/4.0.0'} -ET.register_namespace('', namespaces['xmlns']) - -# Find the element -dependencies = root.find('xmlns:dependencies', namespaces) - -# Create the JaCoCo dependency element -dependency = ET.SubElement(dependencies, 'dependency') -groupId = ET.SubElement(dependency, 'groupId') -groupId.text = 'org.jacoco' -artifactId = ET.SubElement(dependency, 'artifactId') -artifactId.text = 'jacoco-maven-plugin' -version = ET.SubElement(dependency, 'version') -version.text = '3.2.0' # Replace with the actual version of JaCoCo - -# Write the modified XML back to the pom.xml file -tree.write('$localDirectory/pom.xml', encoding='utf-8', xml_declaration=True) -" - fi -} +# function add_jacoco_dependency { +# if [[ $language == "quarkus"* ]] +# then +# echo "Adding JaCoCo dependency to pom.xml..." +# python3 -c " +# import xml.etree.ElementTree as ET + +# # Parse the pom.xml file +# tree = ET.parse('$localDirectory/pom.xml') +# root = tree.getroot() + +# # Define the namespace +# namespaces = {'xmlns': 'http://maven.apache.org/POM/4.0.0'} +# ET.register_namespace('', namespaces['xmlns']) + +# # Find the element +# dependencies = root.find('xmlns:dependencies', namespaces) + +# # Create the JaCoCo dependency element +# dependency = ET.SubElement(dependencies, 'dependency') +# groupId = ET.SubElement(dependency, 'groupId') +# groupId.text = 'org.jacoco' +# artifactId = ET.SubElement(dependency, 'artifactId') +# artifactId.text = 'jacoco-maven-plugin' +# version = ET.SubElement(dependency, 'version') +# version.text = '3.2.0' # Replace with the actual version of JaCoCo + +# # Write the modified XML back to the pom.xml file +# tree.write('$localDirectory/pom.xml', encoding='utf-8', xml_declaration=True) +# " +# fi +# } obtainHangarPath @@ -194,7 +194,7 @@ copyCommonScript type copyScript &> /dev/null && copyScript -add_jacoco_dependency +#add_jacoco_dependency commitCommonFiles From e7a93a1a2de84555632ed495f6049e523cfb1dbd Mon Sep 17 00:00:00 2001 From: victordrose Date: Thu, 14 Dec 2023 16:29:25 +0100 Subject: [PATCH 07/26] 111 --- scripts/pipelines/azure-devops/pipeline_generator.sh | 2 +- .../common/templates/quality/quarkus-quality.sh.template | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/pipelines/azure-devops/pipeline_generator.sh b/scripts/pipelines/azure-devops/pipeline_generator.sh index a4a0bdaf4..74968b780 100755 --- a/scripts/pipelines/azure-devops/pipeline_generator.sh +++ b/scripts/pipelines/azure-devops/pipeline_generator.sh @@ -163,7 +163,7 @@ function createPR { # artifactId = ET.SubElement(dependency, 'artifactId') # artifactId.text = 'jacoco-maven-plugin' # version = ET.SubElement(dependency, 'version') -# version.text = '3.2.0' # Replace with the actual version of JaCoCo +# version.text = '0.8.7' # Replace with the actual version of JaCoCo # # Write the modified XML back to the pom.xml file # tree.write('$localDirectory/pom.xml', encoding='utf-8', xml_declaration=True) diff --git a/scripts/pipelines/common/templates/quality/quarkus-quality.sh.template b/scripts/pipelines/common/templates/quality/quarkus-quality.sh.template index 7ace273ce..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 -Dsonar.coverage.jacoco.xmlReportPaths=target/site/jacoco/jacoco.xml +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 From 78823debae51911b408e97bb9b5838d71821e93a Mon Sep 17 00:00:00 2001 From: victordrose Date: Fri, 15 Dec 2023 12:45:23 +0100 Subject: [PATCH 08/26] .. --- scripts/pipelines/azure-devops/templates/ci/ci-pipeline.cfg | 4 ++-- scripts/pipelines/common/pipeline_generator.lib | 2 +- .../templates/quality/angular-quality-setup-environment.sh | 0 .../templates/quality/node-quality-setup-environment.sh | 0 4 files changed, 3 insertions(+), 3 deletions(-) rename scripts/pipelines/{azure-devops => common}/templates/quality/angular-quality-setup-environment.sh (100%) rename scripts/pipelines/{azure-devops => common}/templates/quality/node-quality-setup-environment.sh (100%) diff --git a/scripts/pipelines/azure-devops/templates/ci/ci-pipeline.cfg b/scripts/pipelines/azure-devops/templates/ci/ci-pipeline.cfg index f7df4f945..61d11d9bd 100644 --- a/scripts/pipelines/azure-devops/templates/ci/ci-pipeline.cfg +++ b/scripts/pipelines/azure-devops/templates/ci/ci-pipeline.cfg @@ -1,7 +1,7 @@ # Mandatory flags. mandatoryFlags="$pipelineName,$localDirectory,$language,$sonarUrl,$sonarToken" # Path to the templates. -templatesPath=("scripts/pipelines/azure-devops/templates/build" "scripts/pipelines/azure-devops/templates/test" "scripts/pipelines/azure-devops/templates/quality" "scripts/pipelines/azure-devops/templates/ci") +templatesPath="scripts/pipelines/azure-devops/templates/ci" # Path to the common templates folder commonTemplatesPipelinePath=("scripts/pipelines/common/templates/build" "scripts/pipelines/common/templates/test" "scripts/pipelines/common/templates/quality") # YAML file name. @@ -26,7 +26,7 @@ function copyScript { fi # Copy the quality script. cp "${hangarPath}/${commonTemplatesPipelinePath[2]}/${language}-${scriptFile[2]}.template" "${localDirectory}/${scriptFilePath}/${scriptFile[2]}" - ! [ -f "${hangarPath}/${templatesPath[2]}/${language}-${setupScriptFile}" ] || cp "${hangarPath}/${templatesPath[2]}/${language}-${setupScriptFile}" "${localDirectory}/${scriptFilePath}/${setupScriptFile}" + ! [ -f "${hangarPath}/${commonTemplatesPipelinePath[2]}/${language}-${setupScriptFile}" ] || cp "${hangarPath}/${commonTemplatesPipelinePath[2]}/${language}-${setupScriptFile}" "${localDirectory}/${scriptFilePath}/${setupScriptFile}" } # Function that adds the variables to be used in the pipeline. diff --git a/scripts/pipelines/common/pipeline_generator.lib b/scripts/pipelines/common/pipeline_generator.lib index eed2f0655..809eaeeed 100644 --- a/scripts/pipelines/common/pipeline_generator.lib +++ b/scripts/pipelines/common/pipeline_generator.lib @@ -213,7 +213,7 @@ function copyYAMLFile { # Generate pipeline YAML from template and put it in the repository. # We cannot use a variable in the definition of resource in the pipeline so we have to use a placeholder to replace it with the value we need commonEnvSubstList='${buildPipelineName} ${testPipelineName} ${qualityPipelineName} ${pipelineName} ${ciPipelineName} ${packagePipelineName}' - envsubst "${commonEnvSubstList} ${specificEnvSubstList}" < "${hangarPath}/${templatesPath[3]}/${yamlFile}.template" > "${localDirectory}/${pipelinePath}/${yamlFile}" + envsubst "${commonEnvSubstList} ${specificEnvSubstList}" < "${hangarPath}/${templatesPath}/${yamlFile}.template" > "${localDirectory}/${pipelinePath}/${yamlFile}" # Check if an extra artifact to store is supplied. if test -n "$artifactPath" diff --git a/scripts/pipelines/azure-devops/templates/quality/angular-quality-setup-environment.sh b/scripts/pipelines/common/templates/quality/angular-quality-setup-environment.sh similarity index 100% rename from scripts/pipelines/azure-devops/templates/quality/angular-quality-setup-environment.sh rename to scripts/pipelines/common/templates/quality/angular-quality-setup-environment.sh diff --git a/scripts/pipelines/azure-devops/templates/quality/node-quality-setup-environment.sh b/scripts/pipelines/common/templates/quality/node-quality-setup-environment.sh similarity index 100% rename from scripts/pipelines/azure-devops/templates/quality/node-quality-setup-environment.sh rename to scripts/pipelines/common/templates/quality/node-quality-setup-environment.sh From ca137671280401d741fd4b62aa52230cd776a259 Mon Sep 17 00:00:00 2001 From: victordrose Date: Wed, 20 Dec 2023 11:34:13 +0100 Subject: [PATCH 09/26] added jacoco dependencies function --- .../azure-devops/pipeline_generator.sh | 35 ++----------------- .../pipelines/common/pipeline_generator.lib | 35 +++++++++++++++++++ 2 files changed, 37 insertions(+), 33 deletions(-) diff --git a/scripts/pipelines/azure-devops/pipeline_generator.sh b/scripts/pipelines/azure-devops/pipeline_generator.sh index 74968b780..3b5b05b54 100755 --- a/scripts/pipelines/azure-devops/pipeline_generator.sh +++ b/scripts/pipelines/azure-devops/pipeline_generator.sh @@ -138,39 +138,6 @@ function createPR { fi } -# function add_jacoco_dependency { -# if [[ $language == "quarkus"* ]] -# then -# echo "Adding JaCoCo dependency to pom.xml..." -# python3 -c " -# import xml.etree.ElementTree as ET - -# # Parse the pom.xml file -# tree = ET.parse('$localDirectory/pom.xml') -# root = tree.getroot() - -# # Define the namespace -# namespaces = {'xmlns': 'http://maven.apache.org/POM/4.0.0'} -# ET.register_namespace('', namespaces['xmlns']) - -# # Find the element -# dependencies = root.find('xmlns:dependencies', namespaces) - -# # Create the JaCoCo dependency element -# dependency = ET.SubElement(dependencies, 'dependency') -# groupId = ET.SubElement(dependency, 'groupId') -# groupId.text = 'org.jacoco' -# artifactId = ET.SubElement(dependency, 'artifactId') -# artifactId.text = 'jacoco-maven-plugin' -# version = ET.SubElement(dependency, 'version') -# version.text = '0.8.7' # Replace with the actual version of JaCoCo - -# # Write the modified XML back to the pom.xml file -# tree.write('$localDirectory/pom.xml', encoding='utf-8', xml_declaration=True) -# " -# fi -# } - obtainHangarPath # Load common functions @@ -190,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..5ad6ed2be 100644 --- a/scripts/pipelines/common/pipeline_generator.lib +++ b/scripts/pipelines/common/pipeline_generator.lib @@ -292,3 +292,38 @@ function languageVersionVerification { exit 2 fi } + +function add_jacoco_dependency { + if [[ "$language" == "quarkus" ]] || [[ "$language" == "quarkus-jvm" ]]; then + echo -e "${green}Adding Jacoco plugin dependencies to pom.xml..." + echo -ne ${white} + + # Define the Jacoco plugin + jacoco_plugin=$(cat <<-END + + org.jacoco + jacoco-maven-plugin + 0.8.7 + + + + prepare-agent + + + + + report + test + + report + + + + +END + ) + + # Insert the Jacoco plugin into the pom.xml file + sed -i "/<\/plugins>/i $jacoco_plugin" "${localDirectory}/pom.xml" + fi +} \ No newline at end of file From ea86888f1507e15966dc6b8e9d76208d95d713ce Mon Sep 17 00:00:00 2001 From: victordrose Date: Wed, 20 Dec 2023 11:49:52 +0100 Subject: [PATCH 10/26] . --- .../azure-devops/pipeline_generator.sh | 2 -- .../pipelines/common/pipeline_generator.lib | 31 +++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/scripts/pipelines/azure-devops/pipeline_generator.sh b/scripts/pipelines/azure-devops/pipeline_generator.sh index 3b5b05b54..5423f3575 100755 --- a/scripts/pipelines/azure-devops/pipeline_generator.sh +++ b/scripts/pipelines/azure-devops/pipeline_generator.sh @@ -163,8 +163,6 @@ copyCommonScript type copyScript &> /dev/null && copyScript -#add_jacoco_dependency - commitCommonFiles type commitFiles &> /dev/null && commitFiles diff --git a/scripts/pipelines/common/pipeline_generator.lib b/scripts/pipelines/common/pipeline_generator.lib index 5ad6ed2be..0f4c313f4 100644 --- a/scripts/pipelines/common/pipeline_generator.lib +++ b/scripts/pipelines/common/pipeline_generator.lib @@ -292,6 +292,37 @@ function languageVersionVerification { exit 2 fi } +function add_jacoco_dependency { + if [[ "$language" == "quarkus" ]] || [[ "$language" == "quarkus-jvn" ]]; 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 + sed -i.bak "/<\/plugins>/i \ + $jacoco_plugin" "${localDirectory}/pom.xml" + fi +} function add_jacoco_dependency { if [[ "$language" == "quarkus" ]] || [[ "$language" == "quarkus-jvm" ]]; then From 881b76153e1f9c6327d6de04602151f5dcd08dfb Mon Sep 17 00:00:00 2001 From: victordrose Date: Wed, 20 Dec 2023 11:58:16 +0100 Subject: [PATCH 11/26] a --- scripts/pipelines/common/pipeline_generator.lib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/pipelines/common/pipeline_generator.lib b/scripts/pipelines/common/pipeline_generator.lib index 0f4c313f4..699a4f564 100644 --- a/scripts/pipelines/common/pipeline_generator.lib +++ b/scripts/pipelines/common/pipeline_generator.lib @@ -355,6 +355,6 @@ END ) # Insert the Jacoco plugin into the pom.xml file - sed -i "/<\/plugins>/i $jacoco_plugin" "${localDirectory}/pom.xml" + sed -i "/<\/plugins>/a $jacoco_plugin" "${localDirectory}/pom.xml" fi } \ No newline at end of file From 01585c613b8bedf56e2966bdc4e27221ea0bd188 Mon Sep 17 00:00:00 2001 From: victordrose Date: Wed, 20 Dec 2023 12:08:18 +0100 Subject: [PATCH 12/26] added xmlstarlet --- scripts/pipelines/common/pipeline_generator.lib | 3 ++- scripts/pipelines/common/templates/build/quarkus-build.sh | 5 ++++- .../pipelines/common/templates/build/quarkus-jvm-build.sh | 5 ++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/scripts/pipelines/common/pipeline_generator.lib b/scripts/pipelines/common/pipeline_generator.lib index 699a4f564..81147643e 100644 --- a/scripts/pipelines/common/pipeline_generator.lib +++ b/scripts/pipelines/common/pipeline_generator.lib @@ -355,6 +355,7 @@ END ) # Insert the Jacoco plugin into the pom.xml file - sed -i "/<\/plugins>/a $jacoco_plugin" "${localDirectory}/pom.xml" + xmlstarlet ed -L -s /project/build/plugins -t elem -n plugin -v "$jacoco_plugin" "${localDirectory}/pom.xml" + fi } \ No newline at end of file diff --git a/scripts/pipelines/common/templates/build/quarkus-build.sh b/scripts/pipelines/common/templates/build/quarkus-build.sh index bf6bf918c..411ad090d 100755 --- a/scripts/pipelines/common/templates/build/quarkus-build.sh +++ b/scripts/pipelines/common/templates/build/quarkus-build.sh @@ -1,2 +1,5 @@ #!/bin/bash -mvn package -B -Pnative \ No newline at end of file +mvn package -B -Pnative + +#installs xmlstarlet to add dependencies +apt-get install xmlstarlet \ No newline at end of file diff --git a/scripts/pipelines/common/templates/build/quarkus-jvm-build.sh b/scripts/pipelines/common/templates/build/quarkus-jvm-build.sh index 91082ed41..0c47d121e 100755 --- a/scripts/pipelines/common/templates/build/quarkus-jvm-build.sh +++ b/scripts/pipelines/common/templates/build/quarkus-jvm-build.sh @@ -1,2 +1,5 @@ #!/bin/bash -mvn package -B \ No newline at end of file +mvn package -B + +#installs xmlstarlet to add dependencies +apt-get install xmlstarlet \ No newline at end of file From 3f32edc214200bcba7997a7ffcdfeb8b020df88a Mon Sep 17 00:00:00 2001 From: victordrose Date: Wed, 20 Dec 2023 12:12:26 +0100 Subject: [PATCH 13/26] trying with awk --- .../pipelines/common/pipeline_generator.lib | 82 ++++++------------- .../common/templates/build/quarkus-build.sh | 3 - .../templates/build/quarkus-jvm-build.sh | 3 - 3 files changed, 25 insertions(+), 63 deletions(-) diff --git a/scripts/pipelines/common/pipeline_generator.lib b/scripts/pipelines/common/pipeline_generator.lib index 81147643e..32b79b2a0 100644 --- a/scripts/pipelines/common/pipeline_generator.lib +++ b/scripts/pipelines/common/pipeline_generator.lib @@ -292,70 +292,38 @@ function languageVersionVerification { exit 2 fi } + function add_jacoco_dependency { if [[ "$language" == "quarkus" ]] || [[ "$language" == "quarkus-jvn" ]]; 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 - - - - " + jacoco_plugin="\ + \ + \norg.jacoco\ + \njacoco-maven-plugin\ + \n0.8.7\ + \n\ + \n\ + \n\ + \nprepare-agent\ + \n\ + \n\ + \n\ + \nreport\ + \nprepare-package\ + \n\ + \nreport\ + \n\ + \n\ + \n\ + \n" + + # Identify the line number where section ends + line_number=$(grep -n "" "${localDirectory}/pom.xml" | cut -d : -f 1) # Insert the Jacoco plugin into the pom.xml file - sed -i.bak "/<\/plugins>/i \ - $jacoco_plugin" "${localDirectory}/pom.xml" + awk -v n=$line_number -v s="$jacoco_plugin" 'NR == n {print s} {print}' "${localDirectory}/pom.xml" > "${localDirectory}/pom.xml.tmp" && mv "${localDirectory}/pom.xml.tmp" "${localDirectory}/pom.xml" fi } - -function add_jacoco_dependency { - if [[ "$language" == "quarkus" ]] || [[ "$language" == "quarkus-jvm" ]]; then - echo -e "${green}Adding Jacoco plugin dependencies to pom.xml..." - echo -ne ${white} - - # Define the Jacoco plugin - jacoco_plugin=$(cat <<-END - - org.jacoco - jacoco-maven-plugin - 0.8.7 - - - - prepare-agent - - - - - report - test - - report - - - - -END - ) - - # Insert the Jacoco plugin into the pom.xml file - xmlstarlet ed -L -s /project/build/plugins -t elem -n plugin -v "$jacoco_plugin" "${localDirectory}/pom.xml" - - fi -} \ No newline at end of file diff --git a/scripts/pipelines/common/templates/build/quarkus-build.sh b/scripts/pipelines/common/templates/build/quarkus-build.sh index 411ad090d..ff58535c9 100755 --- a/scripts/pipelines/common/templates/build/quarkus-build.sh +++ b/scripts/pipelines/common/templates/build/quarkus-build.sh @@ -1,5 +1,2 @@ #!/bin/bash mvn package -B -Pnative - -#installs xmlstarlet to add dependencies -apt-get install xmlstarlet \ No newline at end of file diff --git a/scripts/pipelines/common/templates/build/quarkus-jvm-build.sh b/scripts/pipelines/common/templates/build/quarkus-jvm-build.sh index 0c47d121e..980361a45 100755 --- a/scripts/pipelines/common/templates/build/quarkus-jvm-build.sh +++ b/scripts/pipelines/common/templates/build/quarkus-jvm-build.sh @@ -1,5 +1,2 @@ #!/bin/bash mvn package -B - -#installs xmlstarlet to add dependencies -apt-get install xmlstarlet \ No newline at end of file From 30cd00ee5dda82d25fa94fa46296c2e7c8857f7b Mon Sep 17 00:00:00 2001 From: victordrose Date: Wed, 20 Dec 2023 12:31:23 +0100 Subject: [PATCH 14/26] using temp --- .../pipelines/common/pipeline_generator.lib | 78 ++++++++++++------- 1 file changed, 51 insertions(+), 27 deletions(-) diff --git a/scripts/pipelines/common/pipeline_generator.lib b/scripts/pipelines/common/pipeline_generator.lib index 32b79b2a0..255dc1156 100644 --- a/scripts/pipelines/common/pipeline_generator.lib +++ b/scripts/pipelines/common/pipeline_generator.lib @@ -292,38 +292,62 @@ function languageVersionVerification { exit 2 fi } - function add_jacoco_dependency { if [[ "$language" == "quarkus" ]] || [[ "$language" == "quarkus-jvn" ]]; then echo -e "${green}Adding Jacoco plugin dependencies to pom.xml..." echo -ne ${white} # Define the Jacoco plugin - jacoco_plugin="\ - \ - \norg.jacoco\ - \njacoco-maven-plugin\ - \n0.8.7\ - \n\ - \n\ - \n\ - \nprepare-agent\ - \n\ - \n\ - \n\ - \nreport\ - \nprepare-package\ - \n\ - \nreport\ - \n\ - \n\ - \n\ - \n" - - # Identify the line number where section ends - line_number=$(grep -n "" "${localDirectory}/pom.xml" | cut -d : -f 1) - - # Insert the Jacoco plugin into the pom.xml file - awk -v n=$line_number -v s="$jacoco_plugin" 'NR == n {print s} {print}' "${localDirectory}/pom.xml" > "${localDirectory}/pom.xml.tmp" && mv "${localDirectory}/pom.xml.tmp" "${localDirectory}/pom.xml" + jacoco_plugin= + + + org.jacoco + jacoco-maven-plugin + 0.8.7 + + + + prepare-agent + + + + + report + test + + report + + + + + + # Create a temporary file + temp_file=$(mktemp) + + # Set a flag to indicate when to insert the Jacoco plugin + insert_jacoco=false + + # Read the pom.xml file line by line + while IFS= read -r line + do + # If the line contains the tag, set the flag to insert the Jacoco plugin + if [[ "$line" == *""* ]]; then + insert_jacoco=true + fi + + # If the flag is set, insert the Jacoco plugin + if [[ "$insert_jacoco" == true ]]; then + echo "$jacoco_plugin" >> "$temp_file" + insert_jacoco=false + fi + + # Write the line to the temporary file + echo "$line" >> "$temp_file" + done < "${localDirectory}/pom.xml" + + # Replace the pom.xml file with the temporary file + mv "$temp_file" "${localDirectory}/pom.xml" fi } + + From e0a2b7fa19c588b29c9bf2fd43178aafe8ed3ade Mon Sep 17 00:00:00 2001 From: victordrose Date: Wed, 20 Dec 2023 12:33:49 +0100 Subject: [PATCH 15/26] . --- scripts/pipelines/common/pipeline_generator.lib | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/scripts/pipelines/common/pipeline_generator.lib b/scripts/pipelines/common/pipeline_generator.lib index 255dc1156..d207ca74c 100644 --- a/scripts/pipelines/common/pipeline_generator.lib +++ b/scripts/pipelines/common/pipeline_generator.lib @@ -298,9 +298,7 @@ function add_jacoco_dependency { echo -ne ${white} # Define the Jacoco plugin - jacoco_plugin= - - + jacoco_plugin= org.jacoco jacoco-maven-plugin 0.8.7 From 916abf185a3247a004caa4ee178ef0f800eccb8a Mon Sep 17 00:00:00 2001 From: victordrose Date: Wed, 20 Dec 2023 12:35:14 +0100 Subject: [PATCH 16/26] . --- scripts/pipelines/common/pipeline_generator.lib | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/pipelines/common/pipeline_generator.lib b/scripts/pipelines/common/pipeline_generator.lib index d207ca74c..c1d8d3e5a 100644 --- a/scripts/pipelines/common/pipeline_generator.lib +++ b/scripts/pipelines/common/pipeline_generator.lib @@ -298,7 +298,8 @@ function add_jacoco_dependency { echo -ne ${white} # Define the Jacoco plugin - jacoco_plugin= + jacoco_plugin= + " org.jacoco jacoco-maven-plugin 0.8.7 @@ -317,7 +318,7 @@ function add_jacoco_dependency { - + " # Create a temporary file temp_file=$(mktemp) From e4bc6c8bb6baf5852ca885648a0b88b5f5645ab5 Mon Sep 17 00:00:00 2001 From: victordrose Date: Wed, 20 Dec 2023 13:04:25 +0100 Subject: [PATCH 17/26] m --- scripts/pipelines/common/pipeline_generator.lib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/pipelines/common/pipeline_generator.lib b/scripts/pipelines/common/pipeline_generator.lib index c1d8d3e5a..68532776c 100644 --- a/scripts/pipelines/common/pipeline_generator.lib +++ b/scripts/pipelines/common/pipeline_generator.lib @@ -293,7 +293,7 @@ function languageVersionVerification { fi } function add_jacoco_dependency { - if [[ "$language" == "quarkus" ]] || [[ "$language" == "quarkus-jvn" ]]; then + if [[ "$language" == "quarkus" ]] || [[ "$language" == "quarkus-jvm" ]]; then echo -e "${green}Adding Jacoco plugin dependencies to pom.xml..." echo -ne ${white} From 817c87080cdd316d62e25bc2784155aa3c658b99 Mon Sep 17 00:00:00 2001 From: victordrose Date: Wed, 20 Dec 2023 13:09:48 +0100 Subject: [PATCH 18/26] m --- scripts/pipelines/common/pipeline_generator.lib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/pipelines/common/pipeline_generator.lib b/scripts/pipelines/common/pipeline_generator.lib index 68532776c..03faf8691 100644 --- a/scripts/pipelines/common/pipeline_generator.lib +++ b/scripts/pipelines/common/pipeline_generator.lib @@ -293,7 +293,7 @@ function languageVersionVerification { fi } function add_jacoco_dependency { - if [[ "$language" == "quarkus" ]] || [[ "$language" == "quarkus-jvm" ]]; then + if [[ "$language" == "quarkus"* ]]; then echo -e "${green}Adding Jacoco plugin dependencies to pom.xml..." echo -ne ${white} From ac8ff20eef96ca57b67e85ff33931802af62f7a4 Mon Sep 17 00:00:00 2001 From: victordrose Date: Wed, 20 Dec 2023 13:20:36 +0100 Subject: [PATCH 19/26] ... --- .../pipelines/common/pipeline_generator.lib | 74 +++++++------------ 1 file changed, 26 insertions(+), 48 deletions(-) diff --git a/scripts/pipelines/common/pipeline_generator.lib b/scripts/pipelines/common/pipeline_generator.lib index 03faf8691..bacb1a2ac 100644 --- a/scripts/pipelines/common/pipeline_generator.lib +++ b/scripts/pipelines/common/pipeline_generator.lib @@ -298,54 +298,32 @@ function add_jacoco_dependency { echo -ne ${white} # Define the Jacoco plugin - jacoco_plugin= - " - org.jacoco - jacoco-maven-plugin - 0.8.7 - - - - prepare-agent - - - - - report - test - - report - - - - " - - # Create a temporary file - temp_file=$(mktemp) - - # Set a flag to indicate when to insert the Jacoco plugin - insert_jacoco=false - - # Read the pom.xml file line by line - while IFS= read -r line - do - # If the line contains the tag, set the flag to insert the Jacoco plugin - if [[ "$line" == *""* ]]; then - insert_jacoco=true - fi - - # If the flag is set, insert the Jacoco plugin - if [[ "$insert_jacoco" == true ]]; then - echo "$jacoco_plugin" >> "$temp_file" - insert_jacoco=false - fi - - # Write the line to the temporary file - echo "$line" >> "$temp_file" - done < "${localDirectory}/pom.xml" - - # Replace the pom.xml file with the temporary file - mv "$temp_file" "${localDirectory}/pom.xml" + jacoco_plugin="\ + \ + \norg.jacoco\ + \njacoco-maven-plugin\ + \n0.8.7\ + \n\ + \n\ + \n\ + \nprepare-agent\ + \n\ + \n\ + \n\ + \nreport\ + \nprepare-package\ + \n\ + \nreport\ + \n\ + \n\ + \n\ + \n" + + # Identify the line number where section ends + line_number=$(grep -n "" "${localDirectory}/pom.xml" | cut -d : -f 1) + + # Insert the Jacoco plugin into the pom.xml file + awk -v n=$line_number -v s="$jacoco_plugin" 'NR == n {print s} {print}' "${localDirectory}/pom.xml" > "${localDirectory}/pom.xml.tmp" && mv "${localDirectory}/pom.xml.tmp" "${localDirectory}/pom.xml" fi } From 038240913cee03f804a70d7c243d651106a76fbe Mon Sep 17 00:00:00 2001 From: victordrose Date: Wed, 20 Dec 2023 13:30:25 +0100 Subject: [PATCH 20/26] mmm --- .../pipelines/common/pipeline_generator.lib | 74 ++++++++++++------- 1 file changed, 48 insertions(+), 26 deletions(-) diff --git a/scripts/pipelines/common/pipeline_generator.lib b/scripts/pipelines/common/pipeline_generator.lib index bacb1a2ac..f20d0ed00 100644 --- a/scripts/pipelines/common/pipeline_generator.lib +++ b/scripts/pipelines/common/pipeline_generator.lib @@ -293,38 +293,60 @@ function languageVersionVerification { fi } function add_jacoco_dependency { - if [[ "$language" == "quarkus"* ]]; then + if [[ "$language" == "quarkus" ]] || [[ "$language" == "quarkus-jvn" ]]; then echo -e "${green}Adding Jacoco plugin dependencies to pom.xml..." echo -ne ${white} # Define the Jacoco plugin jacoco_plugin="\ - \ - \norg.jacoco\ - \njacoco-maven-plugin\ - \n0.8.7\ - \n\ - \n\ - \n\ - \nprepare-agent\ - \n\ - \n\ - \n\ - \nreport\ - \nprepare-package\ - \n\ - \nreport\ - \n\ - \n\ - \n\ - \n" - - # Identify the line number where section ends - line_number=$(grep -n "" "${localDirectory}/pom.xml" | cut -d : -f 1) - - # Insert the Jacoco plugin into the pom.xml file - awk -v n=$line_number -v s="$jacoco_plugin" 'NR == n {print s} {print}' "${localDirectory}/pom.xml" > "${localDirectory}/pom.xml.tmp" && mv "${localDirectory}/pom.xml.tmp" "${localDirectory}/pom.xml" +\ +\norg.jacoco\ +\njacoco-maven-plugin\ +\n0.8.7\ +\n\ +\n\ +\n\ +\nprepare-agent\ +\n\ +\n\ +\n\ +\nreport\ +\nprepare-package\ +\n\ +\nreport\ +\n\ +\n\ +\n\ +\n" + + # Create a temporary file + temp_file=$(mktemp) + + # Set a flag to indicate when to insert the Jacoco plugin + insert_jacoco=false + + # Read the pom.xml file line by line + while IFS= read -r line + do + # If the line contains the tag, set the flag to insert the Jacoco plugin + if [[ "$line" == *""* ]]; then + insert_jacoco=true + fi + + # If the flag is set, insert the Jacoco plugin + if [[ "$insert_jacoco" == true ]]; then + printf "$jacoco_plugin" >> "$temp_file" + insert_jacoco=false + fi + + # Write the line to the temporary file + printf "$line\n" >> "$temp_file" + done < "${localDirectory}/pom.xml" + + # Replace the pom.xml file with the temporary file + mv "$temp_file" "${localDirectory}/pom.xml" fi } + From 434c014448d0387366fa83a2151145e52f9288c7 Mon Sep 17 00:00:00 2001 From: victordrose Date: Wed, 20 Dec 2023 13:32:14 +0100 Subject: [PATCH 21/26] aaa --- scripts/pipelines/common/pipeline_generator.lib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/pipelines/common/pipeline_generator.lib b/scripts/pipelines/common/pipeline_generator.lib index f20d0ed00..c99f648c7 100644 --- a/scripts/pipelines/common/pipeline_generator.lib +++ b/scripts/pipelines/common/pipeline_generator.lib @@ -293,7 +293,7 @@ function languageVersionVerification { fi } function add_jacoco_dependency { - if [[ "$language" == "quarkus" ]] || [[ "$language" == "quarkus-jvn" ]]; then + if [[ "$language" == "quarkus"* ]]; then echo -e "${green}Adding Jacoco plugin dependencies to pom.xml..." echo -ne ${white} From cbbf99215ba2181cd444d7cbbcb748297631e5d4 Mon Sep 17 00:00:00 2001 From: victordrose Date: Wed, 20 Dec 2023 13:43:57 +0100 Subject: [PATCH 22/26] python script --- .../pipelines/common/pipeline_generator.lib | 81 ++++++++----------- 1 file changed, 32 insertions(+), 49 deletions(-) diff --git a/scripts/pipelines/common/pipeline_generator.lib b/scripts/pipelines/common/pipeline_generator.lib index c99f648c7..de11de1f6 100644 --- a/scripts/pipelines/common/pipeline_generator.lib +++ b/scripts/pipelines/common/pipeline_generator.lib @@ -298,55 +298,38 @@ function add_jacoco_dependency { echo -ne ${white} # Define the Jacoco plugin - jacoco_plugin="\ -\ -\norg.jacoco\ -\njacoco-maven-plugin\ -\n0.8.7\ -\n\ -\n\ -\n\ -\nprepare-agent\ -\n\ -\n\ -\n\ -\nreport\ -\nprepare-package\ -\n\ -\nreport\ -\n\ -\n\ -\n\ -\n" - - # Create a temporary file - temp_file=$(mktemp) - - # Set a flag to indicate when to insert the Jacoco plugin - insert_jacoco=false - - # Read the pom.xml file line by line - while IFS= read -r line - do - # If the line contains the tag, set the flag to insert the Jacoco plugin - if [[ "$line" == *""* ]]; then - insert_jacoco=true - fi - - # If the flag is set, insert the Jacoco plugin - if [[ "$insert_jacoco" == true ]]; then - printf "$jacoco_plugin" >> "$temp_file" - insert_jacoco=false - fi - - # Write the line to the temporary file - printf "$line\n" >> "$temp_file" - done < "${localDirectory}/pom.xml" - - # Replace the pom.xml file with the temporary file - mv "$temp_file" "${localDirectory}/pom.xml" + jacoco_plugin=" +org.jacoco +jacoco-maven-plugin +0.8.7 + + + +prepare-agent + + + +report +prepare-package + +report + + + +" + + # Create a Python script to add the Jacoco plugin to the pom.xml file + python_script=$(mktemp) + echo "import xml.etree.ElementTree as ET" >> "$python_script" + echo "tree = ET.parse('${localDirectory}/pom.xml')" >> "$python_script" + echo "root = tree.getroot()" >> "$python_script" + echo "plugins = root.find('.//plugins')" >> "$python_script" + echo "jacoco_plugin = ET.fromstring('''$jacoco_plugin''')" >> "$python_script" + echo "plugins.append(jacoco_plugin)" >> "$python_script" + echo "tree.write('${localDirectory}/pom.xml')" >> "$python_script" + + # Run the Python script + python "$python_script" fi } - - From 5cf6d1972c8bf1309a38dd55d9b95a374b77a1bc Mon Sep 17 00:00:00 2001 From: victordrose Date: Wed, 20 Dec 2023 13:47:46 +0100 Subject: [PATCH 23/26] qqqq --- scripts/pipelines/common/pipeline_generator.lib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/pipelines/common/pipeline_generator.lib b/scripts/pipelines/common/pipeline_generator.lib index de11de1f6..ad195f4f9 100644 --- a/scripts/pipelines/common/pipeline_generator.lib +++ b/scripts/pipelines/common/pipeline_generator.lib @@ -323,7 +323,7 @@ function add_jacoco_dependency { echo "import xml.etree.ElementTree as ET" >> "$python_script" echo "tree = ET.parse('${localDirectory}/pom.xml')" >> "$python_script" echo "root = tree.getroot()" >> "$python_script" - echo "plugins = root.find('.//plugins')" >> "$python_script" + echo "plugins = root.find('.//build/plugins')" >> "$python_script" echo "jacoco_plugin = ET.fromstring('''$jacoco_plugin''')" >> "$python_script" echo "plugins.append(jacoco_plugin)" >> "$python_script" echo "tree.write('${localDirectory}/pom.xml')" >> "$python_script" From e3e300d5a627cf098004f6b310d2a786383b44f0 Mon Sep 17 00:00:00 2001 From: victordrose Date: Wed, 20 Dec 2023 14:03:28 +0100 Subject: [PATCH 24/26] now with perl --- scripts/pipelines/common/pipeline_generator.lib | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/scripts/pipelines/common/pipeline_generator.lib b/scripts/pipelines/common/pipeline_generator.lib index ad195f4f9..7cb314960 100644 --- a/scripts/pipelines/common/pipeline_generator.lib +++ b/scripts/pipelines/common/pipeline_generator.lib @@ -318,18 +318,7 @@ function add_jacoco_dependency { " - # Create a Python script to add the Jacoco plugin to the pom.xml file - python_script=$(mktemp) - echo "import xml.etree.ElementTree as ET" >> "$python_script" - echo "tree = ET.parse('${localDirectory}/pom.xml')" >> "$python_script" - echo "root = tree.getroot()" >> "$python_script" - echo "plugins = root.find('.//build/plugins')" >> "$python_script" - echo "jacoco_plugin = ET.fromstring('''$jacoco_plugin''')" >> "$python_script" - echo "plugins.append(jacoco_plugin)" >> "$python_script" - echo "tree.write('${localDirectory}/pom.xml')" >> "$python_script" - - # Run the Python script - python "$python_script" + # Insert the Jacoco plugin into the pom.xml file + perl -i -pe "s||${jacoco_plugin}\n|g" "${localDirectory}/pom.xml" fi } - From 3a661ff93be63477280715852e7fd4c71b39145c Mon Sep 17 00:00:00 2001 From: victordrose Date: Wed, 20 Dec 2023 14:13:53 +0100 Subject: [PATCH 25/26] solving problem with commit --- scripts/pipelines/common/pipeline_generator.lib | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/pipelines/common/pipeline_generator.lib b/scripts/pipelines/common/pipeline_generator.lib index 7cb314960..868ac1e13 100644 --- a/scripts/pipelines/common/pipeline_generator.lib +++ b/scripts/pipelines/common/pipeline_generator.lib @@ -268,6 +268,9 @@ function commitCommonFiles { # Add the YAML files. git add "$pipelinePath" -f + # Add the changes in the pom.xml file + git add "pom.xml" + # 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 {} \; From ac1aa40683ea0ed515d3a45d50cca217c0b9456f Mon Sep 17 00:00:00 2001 From: victordrose Date: Thu, 21 Dec 2023 10:00:22 +0100 Subject: [PATCH 26/26] added conditional for pom.xml to commitCommonFiles function --- scripts/pipelines/common/pipeline_generator.lib | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/pipelines/common/pipeline_generator.lib b/scripts/pipelines/common/pipeline_generator.lib index 868ac1e13..e90cddb6b 100644 --- a/scripts/pipelines/common/pipeline_generator.lib +++ b/scripts/pipelines/common/pipeline_generator.lib @@ -268,8 +268,11 @@ function commitCommonFiles { # Add the YAML files. git add "$pipelinePath" -f - # Add the changes in the pom.xml file - git add "pom.xml" + # 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