Fix: Update lf-activate-venv
[releng/builder.git] / jjb / integration / integration-upload-distribution.sh
index 9289c55687dbe4e92413b9f7a1744f358fc8e4dd..7b09aa1f32607eaa0a09664bdea319f9594b80ec 100644 (file)
@@ -1,29 +1,49 @@
 #!/bin/bash
 set -xeu -o pipefail
 
-BUNDLE_VERSION=$(xpath "${BUNDLE_POM}" '/project/version/text()' 2> /dev/null)
-BUNDLE="${KARAF_ARTIFACT}-${BUNDLE_VERSION}.zip"
-BUNDLE_FILEPATH="/tmp/r/org/opendaylight/integration/${KARAF_ARTIFACT}/${BUNDLE_VERSION}/${BUNDLE}"
-ls -l "${BUNDLE_FILEPATH}"
+# 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}"
+if [[ "$KARAF_PROJECT" == "integration" ]]; then
+    GROUP_ID="org.opendaylight.${KARAF_PROJECT}.${GERRIT_PROJECT//\//.}"
+else
+    GROUP_ID="org.opendaylight.${KARAF_PROJECT}"
+fi
+
+echo "Bundle folder is ${BUNDLEFOLDER}"
+echo "Bundle is ${BUNDLE}"
+echo "Bundle path is ${BUNDLE_PATH}"
+echo "Group ID is ${GROUP_ID}"
+
+ls -l "${BUNDLE_PATH}"
 LOG_FILE='integration-upload-distribution.log'
 echo "Uploading distribution to Nexus..."
 "$MVN" deploy:deploy-file \
     --log-file ${LOG_FILE} \
     --global-settings "$GLOBAL_SETTINGS_FILE" \
     --settings "$SETTINGS_FILE" \
-    -Dfile="${BUNDLE_FILEPATH}" \
+    -Dfile="${BUNDLE_PATH}" \
     -DrepositoryId=opendaylight-snapshot \
     -Durl="$ODLNEXUSPROXY/content/repositories/opendaylight.snapshot/" \
-    -DgroupId="org.opendaylight.integration.${GERRIT_PROJECT//\//.}" \
-    -DartifactId=${KARAF_ARTIFACT} \
+    -DgroupId="${GROUP_ID}" \
+    -DartifactId="${KARAF_ARTIFACT}" \
     -Dversion="${BUNDLE_VERSION}" \
     -Dpackaging=zip \
     || true  # Sandbox is not allowed to uplad to Nexus.
 
 cat "${LOG_FILE}"
 
-BUNDLE_URL=$(grep "Uploaded.*${KARAF_ARTIFACT}/${BUNDLE_VERSION}.*.zip" ${LOG_FILE} | awk '{print $3}') || true
+BUNDLE_URL=$(grep "Uploaded.*${KARAF_ARTIFACT}/${BUNDLE_VERSION}.*.zip" ${LOG_FILE} | awk '{print $5}') || true
 echo "Bundle uploaded to ${BUNDLE_URL}"
 
 # Re-inject the new BUNDLE_URL for downstream jobs to pull from Nexus
-env | grep BUNDLE_ | sort | tee integration-upload-distribution.env
+cat > "${WORKSPACE}/integration-upload-distribution.env" <<EOF
+BUNDLE_URL=${BUNDLE_URL}
+BUNDLE_VERSION=${BUNDLE_VERSION}
+BUNDLEFOLDER=${BUNDLEFOLDER}
+BUNDLE=${BUNDLE}
+BUNDLE_PATH=${BUNDLE_PATH}
+EOF