Auto Update CSIT Jobs to run for chlorine
[releng/builder.git] / jjb / integration / integration-upload-distribution.sh
1 #!/bin/bash
2 set -xeu -o pipefail
3
4 BUNDLE_VERSION=$(xpath "${BUNDLE_POM}" '/project/version/text()' 2> /dev/null)
5 BUNDLEFOLDER="${KARAF_ARTIFACT}-${BUNDLE_VERSION}"
6 BUNDLE="${BUNDLEFOLDER}.zip"
7 BUNDLE_PATH="/tmp/r/org/opendaylight/${KARAF_PROJECT}/${KARAF_ARTIFACT}/${BUNDLE_VERSION}/${BUNDLE}"
8 if [[ "$KARAF_PROJECT" == "integration" ]]; then
9     GROUP_ID="org.opendaylight.${KARAF_PROJECT}.${GERRIT_PROJECT//\//.}"
10 else
11     GROUP_ID="org.opendaylight.${KARAF_PROJECT}"
12 fi
13
14 echo "Bundle folder is ${BUNDLEFOLDER}"
15 echo "Bundle is ${BUNDLE}"
16 echo "Bundle path is ${BUNDLE_PATH}"
17 echo "Group ID is ${GROUP_ID}"
18
19 ls -l "${BUNDLE_PATH}"
20 LOG_FILE='integration-upload-distribution.log'
21 echo "Uploading distribution to Nexus..."
22 "$MVN" deploy:deploy-file \
23     --log-file ${LOG_FILE} \
24     --global-settings "$GLOBAL_SETTINGS_FILE" \
25     --settings "$SETTINGS_FILE" \
26     -Dfile="${BUNDLE_PATH}" \
27     -DrepositoryId=opendaylight-snapshot \
28     -Durl="$ODLNEXUSPROXY/content/repositories/opendaylight.snapshot/" \
29     -DgroupId="${GROUP_ID}" \
30     -DartifactId="${KARAF_ARTIFACT}" \
31     -Dversion="${BUNDLE_VERSION}" \
32     -Dpackaging=zip \
33     || true  # Sandbox is not allowed to uplad to Nexus.
34
35 cat "${LOG_FILE}"
36
37 BUNDLE_URL=$(grep "Uploaded.*${KARAF_ARTIFACT}/${BUNDLE_VERSION}.*.zip" ${LOG_FILE} | awk '{print $5}') || true
38 echo "Bundle uploaded to ${BUNDLE_URL}"
39
40 # Re-inject the new BUNDLE_URL for downstream jobs to pull from Nexus
41 cat > "${WORKSPACE}/integration-upload-distribution.env" <<EOF
42 BUNDLE_URL=${BUNDLE_URL}
43 BUNDLE_VERSION=${BUNDLE_VERSION}
44 BUNDLEFOLDER=${BUNDLEFOLDER}
45 BUNDLE=${BUNDLE}
46 BUNDLE_PATH=${BUNDLE_PATH}
47 EOF