Merge "Update Ubuntu docker image"
[releng/builder.git] / jjb / integration / integration-detect-variables.sh
1
2 # TODO: Document the default values.
3 NEXUSURL_PREFIX="${ODLNEXUSPROXY:-https://nexus.opendaylight.org}"
4 ODL_NEXUS_REPO="${ODL_NEXUS_REPO:-content/repositories/opendaylight.snapshot}"
5 GERRIT_PATH="${GERRIT_PATH:-git.opendaylight.org/gerrit}"
6 DISTROBRANCH="${DISTROBRANCH:-$GERRIT_BRANCH}"
7
8 if [ ${BUNDLE_URL} == 'last' ]; then
9     # Obtain current pom.xml of integration/distribution, correct branch.
10     wget "http://${GERRIT_PATH}/gitweb?p=integration/distribution.git;a=blob_plain;f=pom.xml;hb=refs/heads/$DISTROBRANCH" -O "pom.xml"
11     # Extract the BUNDLE_VERSION from the pom.xml
12     BUNDLE_VERSION="$(xpath pom.xml '/project/version/text()' 2> /dev/null)"
13     echo "Bundle version is ${BUNDLE_VERSION}"
14     # Acquire the timestamp information from maven-metadata.xml
15     NEXUSPATH="${NEXUSURL_PREFIX}/${ODL_NEXUS_REPO}/org/opendaylight/integration/${KARAF_ARTIFACT}"
16     wget "${NEXUSPATH}/${BUNDLE_VERSION}/maven-metadata.xml"
17     less "maven-metadata.xml"
18     TIMESTAMP="$(xpath maven-metadata.xml "//snapshotVersion[extension='zip'][1]/value/text()" 2>/dev/null)"
19     echo "Nexus timestamp is ${TIMESTAMP}"
20     BUNDLEFOLDER="${KARAF_ARTIFACT}-${BUNDLE_VERSION}"
21     BUNDLE="${KARAF_ARTIFACT}-${TIMESTAMP}.zip"
22     ACTUAL_BUNDLE_URL="${NEXUSPATH}/${BUNDLE_VERSION}/${BUNDLE}"
23 else
24     ACTUAL_BUNDLE_URL="${BUNDLE_URL}"
25     BUNDLE="${BUNDLE_URL##*/}"
26     ARTIFACT="$(basename "$(dirname "$(dirname "${BUNDLE_URL}")")")"
27     BUNDLE_VERSION="$(basename "$(dirname "${BUNDLE_URL}")")"
28     BUNDLEFOLDER="${ARTIFACT}-${BUNDLE_VERSION}"
29 fi
30
31 echo "Distribution bundle URL is ${ACTUAL_BUNDLE_URL}"
32 echo "Distribution bundle is ${BUNDLE}"
33 echo "Distribution bundle version is ${BUNDLE_VERSION}"
34 echo "Distribution folder is ${BUNDLEFOLDER}"
35 echo "Nexus prefix is ${NEXUSURL_PREFIX}"
36
37 # The following is not a shell file, double quotes would be literal.
38 cat > "${WORKSPACE}/detect_variables.env" <<EOF
39 ACTUAL_BUNDLE_URL=${ACTUAL_BUNDLE_URL}
40 BUNDLE=${BUNDLE}
41 BUNDLE_VERSION=${BUNDLE_VERSION}
42 BUNDLEFOLDER=${BUNDLEFOLDER}
43 NEXUSURL_PREFIX=${NEXUSURL_PREFIX}
44 EOF
45
46 # vim: ts=4 sw=4 sts=4 et ft=sh :