Auto Update CSIT Jobs to run for chlorine
[releng/builder.git] / jjb / integration / integration-detect-variables.sh
1 #!/bin/bash
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     if [[ "$KARAF_ARTIFACT" == "opendaylight" ]]; then
11         wget "http://${GERRIT_PATH}/gitweb?p=integration/distribution.git;a=blob_plain;f=opendaylight/pom.xml;hb=refs/heads/$DISTROBRANCH" -O "pom.xml"
12     elif [[ "$KARAF_ARTIFACT" == "karaf" ]]; then
13         wget "http://${GERRIT_PATH}/gitweb?p=integration/distribution.git;a=blob_plain;f=pom.xml;hb=refs/heads/$DISTROBRANCH" -O "pom.xml"
14     elif [[ "$KARAF_ARTIFACT" == "netconf-karaf" ]]; then
15         wget "http://${GERRIT_PATH}/gitweb?p=${KARAF_PROJECT}.git;a=blob_plain;f=karaf/pom.xml;hb=refs/heads/$DISTROBRANCH" -O "pom.xml"
16     elif [[ "$KARAF_ARTIFACT" == "controller-test-karaf" ]]; then
17         wget "http://${GERRIT_PATH}/gitweb?p=${KARAF_PROJECT}.git;a=blob_plain;f=karaf/pom.xml;hb=refs/heads/$DISTROBRANCH" -O "pom.xml"
18     elif [[ "$KARAF_ARTIFACT" == "bgpcep-karaf" ]]; then
19         wget "http://${GERRIT_PATH}/gitweb?p=${KARAF_PROJECT}.git;a=blob_plain;f=distribution-karaf/pom.xml;hb=refs/heads/$DISTROBRANCH" -O "pom.xml"
20     else
21         wget "http://${GERRIT_PATH}/gitweb?p=integration/distribution.git;a=blob_plain;f=pom.xml;hb=refs/heads/$DISTROBRANCH" -O "pom.xml"
22     fi
23     # Extract the BUNDLE_VERSION from the pom.xml
24     BUNDLE_VERSION="$(xpath pom.xml '/project/version/text()' 2> /dev/null)"
25     echo "Bundle version is ${BUNDLE_VERSION}"
26     # Acquire the timestamp information from maven-metadata.xml
27     NEXUSPATH="${NEXUSURL_PREFIX}/${ODL_NEXUS_REPO}/org/opendaylight/${KARAF_PROJECT}/${KARAF_ARTIFACT}"
28     wget "${NEXUSPATH}/${BUNDLE_VERSION}/maven-metadata.xml"
29     less "maven-metadata.xml"
30     TIMESTAMP="$(xpath maven-metadata.xml "//snapshotVersion[extension='zip'][1]/value/text()" 2>/dev/null)"
31     echo "Nexus timestamp is ${TIMESTAMP}"
32     BUNDLEFOLDER="${KARAF_ARTIFACT}-${BUNDLE_VERSION}"
33     BUNDLE="${KARAF_ARTIFACT}-${TIMESTAMP}.zip"
34     ACTUAL_BUNDLE_URL="${NEXUSPATH}/${BUNDLE_VERSION}/${BUNDLE}"
35 else
36     ACTUAL_BUNDLE_URL="${BUNDLE_URL}"
37     BUNDLE="${BUNDLE_URL##*/}"
38     ARTIFACT="$(basename "$(dirname "$(dirname "${BUNDLE_URL}")")")"
39     BUNDLE_VERSION="$(basename "$(dirname "${BUNDLE_URL}")")"
40     BUNDLEFOLDER="${ARTIFACT}-${BUNDLE_VERSION}"
41 fi
42
43 echo "Distribution bundle URL is ${ACTUAL_BUNDLE_URL}"
44 echo "Distribution bundle is ${BUNDLE}"
45 echo "Distribution bundle version is ${BUNDLE_VERSION}"
46 echo "Distribution folder is ${BUNDLEFOLDER}"
47 echo "Nexus prefix is ${NEXUSURL_PREFIX}"
48
49 # The following is not a shell file, double quotes would be literal.
50 cat > "${WORKSPACE}/detect_variables.env" <<EOF
51 ACTUAL_BUNDLE_URL=${ACTUAL_BUNDLE_URL}
52 BUNDLE=${BUNDLE}
53 BUNDLE_VERSION=${BUNDLE_VERSION}
54 BUNDLEFOLDER=${BUNDLEFOLDER}
55 NEXUSURL_PREFIX=${NEXUSURL_PREFIX}
56 EOF
57
58 # vim: ts=4 sw=4 sts=4 et ft=sh :