Merge "Update validate autorelease projects for oxygen"
[releng/builder.git] / jjb / integration / integration-compare-distributions.sh
1 #!/bin/bash
2
3 # Depends on variables created and published from the integration-set-variables script
4
5 # Do not fail the build if there is trouble trying to collect distribution patch diffs
6 set +e
7
8 NEXUSURL_PREFIX=${ODLNEXUSPROXY:-https://nexus.opendaylight.org}
9 ODL_NEXUS_REPO=${ODL_NEXUS_REPO:-content/repositories/opendaylight.snapshot}
10 GERRIT_PATH=${GERRIT_PATH:-git.opendaylight.org/gerrit}
11 DISTROBRANCH=${DISTROBRANCH:-$GERRIT_BRANCH}
12
13 # Obtain current pom.xml of integration/distribution, correct branch.
14 wget "http://${GERRIT_PATH}/gitweb?p=integration/distribution.git;a=blob_plain;f=pom.xml;hb=refs/heads/$DISTROBRANCH" -O "pom.xml"
15 # Extract the BUNDLEVERSION from the pom.xml
16 BUNDLEVERSION=$(xpath pom.xml '/project/version/text()' 2> /dev/null)
17 echo "Bundle version is ${BUNDLEVERSION}"
18 # Acquire the timestamp information from maven-metadata.xml
19 NEXUSPATH="${NEXUSURL_PREFIX}/${ODL_NEXUS_REPO}/org/opendaylight/integration/${KARAF_ARTIFACT}"
20 wget ${NEXUSPATH}/${BUNDLEVERSION}/maven-metadata.xml
21
22 if [ $? -ne 0 ]; then
23   echo "unable to find maven-metadata.xml. no need to continue..."
24   exit 0
25 fi
26
27 less maven-metadata.xml
28 TIMESTAMP=$(xpath maven-metadata.xml "//snapshotVersion[extension='zip'][1]/value/text()" 2>/dev/null)
29 echo "Nexus timestamp is ${TIMESTAMP}"
30 BUNDLEFOLDER="${KARAF_ARTIFACT}-${BUNDLEVERSION}"
31 BUNDLE="${KARAF_ARTIFACT}-${TIMESTAMP}.zip"
32 ACTUAL_BUNDLE_URL="${NEXUSPATH}/${BUNDLEVERSION}/${BUNDLE}"
33
34 wget --progress=dot:mega $ACTUAL_BUNDLE_URL
35 echo "Extracting the last distribution found on nexus..."
36 unzip -q $BUNDLE
37 mv $BUNDLEFOLDER /tmp/distro_old
38 rm $BUNDLE
39
40 echo "Extracting the distribution just created by this job..."
41 NEW_DISTRO="$(find $WORKSPACE -name "${KARAF_ARTIFACT}*.zip")"
42 NEW_DISTRO_BASENAME="$(basename "$NEW_DISTRO")"
43 cp $NEW_DISTRO /tmp/
44 cd /tmp/ || exit
45 # get the name of the folder which will be extracted to
46 EXTRACTED_FOLDER=$(unzip $NEW_DISTRO_BASENAME | grep 'creating:' | grep -v '/.' | cut -d' ' -f5-)
47 mv $EXTRACTED_FOLDER distro_new
48
49 git clone https://git.opendaylight.org/gerrit/p/integration/test.git
50 cd test/tools/distchanges || exit
51 mkdir -p $WORKSPACE/archives
52
53 # Full output of compare tool will be in temp file /tmp/dist_diff.txt
54 # The file/report to be archived will only list the distribution in the comparison and the patches that
55 # are different.
56 python distcompare.py -r ssh://jenkins-$SILO@git.opendaylight.org:29418 | tee /tmp/dist_diff.txt
57 echo -e "Patch differences listed are in comparison to:\n\t$ACTUAL_BUNDLE_URL\n\n" > $WORKSPACE/archives/distribution_differences.txt
58 sed -ne '/Patch differences/,$ p' /tmp/dist_diff.txt >> $WORKSPACE/archives/distribution_differences.txt