Update xpath commands 45/102145/3
authorSangwook Ha <sangwook.ha@verizon.com>
Thu, 18 Aug 2022 06:07:56 +0000 (23:07 -0700)
committerSangwook Ha <sangwook.ha@verizon.com>
Thu, 18 Aug 2022 17:18:35 +0000 (10:18 -0700)
'xpath' command in CentOS 8 uses the following format:

  xpath [options] -e query [-e query...] [filename...]

instead of this in CentOS 7:

  xpath [filename] query

Update the commands in the shell scripts to follow the new format with
the old one as a fallback to support both versions.

Change-Id: I4a99a7f18e69d2d1c4c67aca16a4a6ab57618cb2
Signed-off-by: Sangwook Ha <sangwook.ha@verizon.com>
jjb/integration/integration-compare-distributions.sh
jjb/integration/integration-detect-variables.sh
jjb/integration/integration-upload-distribution.sh
jjb/releng-maven-mri-stage.sh

index 9dfede50fd0e4880ff448401c642e0fcd5f0bca1..dc694a1eb677bdcc73c4472adc35d6c90a50c961 100644 (file)
@@ -26,7 +26,9 @@ else
 fi
 
 # Extract the BUNDLE_VERSION from the pom.xml
-BUNDLE_VERSION=$(xpath pom.xml '/project/version/text()' 2> /dev/null)
+# TODO: remove the second xpath command once the old version in CentOS 7 is not used any more
+BUNDLE_VERSION=$(xpath -e '/project/version/text()' pom.xml 2>/dev/null ||
+    xpath pom.xml '/project/version/text()' 2>/dev/null)
 echo "Bundle version is ${BUNDLE_VERSION}"
 # Acquire the timestamp information from maven-metadata.xml
 NEXUSPATH="${NEXUSURL_PREFIX}/${ODL_NEXUS_REPO}/org/opendaylight/${KARAF_PROJECT}/${KARAF_ARTIFACT}"
@@ -39,7 +41,9 @@ if [ $? -ne 0 ]; then
 fi
 
 less maven-metadata.xml
-TIMESTAMP=$(xpath maven-metadata.xml "//snapshotVersion[extension='zip'][1]/value/text()" 2>/dev/null)
+# TODO: remove the second xpath command once the old version in CentOS 7 is not used any more
+TIMESTAMP=$(xpath -e "//snapshotVersion[extension='zip'][1]/value/text()" maven-metadata.xml 2>/dev/null ||
+    xpath maven-metadata.xml "//snapshotVersion[extension='zip'][1]/value/text()" 2>/dev/null)
 echo "Nexus timestamp is ${TIMESTAMP}"
 BUNDLEFOLDER="${KARAF_ARTIFACT}-${BUNDLE_VERSION}"
 BUNDLE="${KARAF_ARTIFACT}-${TIMESTAMP}.zip"
@@ -80,4 +84,3 @@ if [ -f /tmp/distro_new/bin/extract_modules.sh ]; then
     /tmp/distro_new/bin/check_modules.sh
     mv /tmp/distro_new/opendaylight-models "$WORKSPACE"/archives
 fi
-
index baaf7183dd8cf698cbf0696eec7ca36cc1a32574..925192c07ec5e32cf83c76b46e8ef6515e1ef4f5 100644 (file)
@@ -21,13 +21,17 @@ if [ "${BUNDLE_URL}" == 'last' ]; then
         wget "http://${GERRIT_PATH}/gitweb?p=integration/distribution.git;a=blob_plain;f=pom.xml;hb=refs/heads/$DISTROBRANCH" -O "pom.xml"
     fi
     # Extract the BUNDLE_VERSION from the pom.xml
-    BUNDLE_VERSION="$(xpath pom.xml '/project/version/text()' 2> /dev/null)"
+    # TODO: remove the second xpath command once the old version in CentOS 7 is not used any more
+    BUNDLE_VERSION=$(xpath -e '/project/version/text()' pom.xml 2>/dev/null ||
+        xpath pom.xml '/project/version/text()' 2>/dev/null)
     echo "Bundle version is ${BUNDLE_VERSION}"
     # Acquire the timestamp information from maven-metadata.xml
     NEXUSPATH="${NEXUSURL_PREFIX}/${ODL_NEXUS_REPO}/org/opendaylight/${KARAF_PROJECT}/${KARAF_ARTIFACT}"
     wget "${NEXUSPATH}/${BUNDLE_VERSION}/maven-metadata.xml"
     less "maven-metadata.xml"
-    TIMESTAMP="$(xpath maven-metadata.xml "//snapshotVersion[extension='zip'][1]/value/text()" 2>/dev/null)"
+    # TODO: remove the second xpath command once the old version in CentOS 7 is not used any more
+    TIMESTAMP=$(xpath -e "//snapshotVersion[extension='zip'][1]/value/text()" maven-metadata.xml 2>/dev/null ||
+        xpath maven-metadata.xml "//snapshotVersion[extension='zip'][1]/value/text()" 2>/dev/null)
     echo "Nexus timestamp is ${TIMESTAMP}"
     BUNDLEFOLDER="${KARAF_ARTIFACT}-${BUNDLE_VERSION}"
     BUNDLE="${KARAF_ARTIFACT}-${TIMESTAMP}.zip"
index 07bba5e61308dda7d9b44aa06dceea089cfbb3dd..7b09aa1f32607eaa0a09664bdea319f9594b80ec 100644 (file)
@@ -1,7 +1,9 @@
 #!/bin/bash
 set -xeu -o pipefail
 
-BUNDLE_VERSION=$(xpath "${BUNDLE_POM}" '/project/version/text()' 2> /dev/null)
+# TODO: remove the second xpath command once the old version in CentOS 7 is not used any more
+BUNDLE_VERSION=$(xpath -e '/project/version/text()' "${BUNDLE_POM}" 2>/dev/null ||
+        xpath "${BUNDLE_POM}" '/project/version/text()' 2>/dev/null)
 BUNDLEFOLDER="${KARAF_ARTIFACT}-${BUNDLE_VERSION}"
 BUNDLE="${BUNDLEFOLDER}.zip"
 BUNDLE_PATH="/tmp/r/org/opendaylight/${KARAF_PROJECT}/${KARAF_ARTIFACT}/${BUNDLE_VERSION}/${BUNDLE}"
index 9dfb7859e00bdd4a51ab04b659a824e42fc6e100..823a03f9622378a6f947f0c4c267aa33050387c2 100644 (file)
@@ -18,7 +18,9 @@ staging_repo=$(sed -n -e 's/Staging repository \(.*\) created\./\1/p' "$TMP_FILE
 mkdir -p "$WORKSPACE/archives"
 echo "$staging_repo ${NEXUS_URL}/content/repositories/$staging_repo" | tee -a "$WORKSPACE/archives/staging-repo.txt"
 
-staged_version=$(find . -name '*karaf*.pom' -exec xpath {} '/project/version/text()' \; 2> /dev/null)
+# TODO: remove the second xpath command once the old version in CentOS 7 is not used any more
+staged_version=$(find . -name '*karaf*.pom' -exec \
+    sh -c 'xpath -e "/project/version/text()" "$1" 2>/dev/null || xpath "$1" "/project/version/text()" 2>/dev/null' xpath.sh {} \;)
 BUNDLE_URL="${NEXUS_URL}/content/repositories/$staging_repo/org/opendaylight/${PROJECT}/${KARAF_ARTIFACT}/${staged_version}/${KARAF_ARTIFACT}-${staged_version}.zip"
 
 # Cleanup