Add Jerma in blacklist logics
[releng.git] / jjb / 3rd_party_ci / download-netvirt-artifact.sh
1 #!/bin/bash
2 set -o errexit
3 set -o nounset
4 set -o pipefail
5
6 echo "Attempting to fetch the artifact location from ODL Jenkins"
7 if [ "$ODL_BRANCH" != 'master' ]; then
8   DIST=$(echo ${ODL_BRANCH} | sed -rn 's#([a-zA-Z]+)/([a-zA-Z]+)#\2#p')
9   ODL_BRANCH=$(echo ${ODL_BRANCH} | sed -rn 's#([a-zA-Z]+)/([a-zA-Z]+)#\1%2F\2#p')
10 else
11   DIST='neon'
12 fi
13
14 echo "ODL Distribution is ${DIST}"
15 ODL_ZIP="karaf-SNAPSHOT.zip"
16 CHANGE_DETAILS_URL="https://git.opendaylight.org/gerrit/changes/${GERRIT_PROJECT}~${ODL_BRANCH}~${GERRIT_CHANGE_ID}/detail"
17 # due to limitation with the Jenkins Gerrit Trigger, we need to use Gerrit REST API to get the change details
18 ODL_BUILD_JOB_NUM=$(curl --fail ${CHANGE_DETAILS_URL} | grep -Eo "${GERRIT_PROJECT}-distribution-check-${DIST}/[0-9]+" | tail -1 | grep -Eo [0-9]+)
19 DISTRO_CHECK_CONSOLE_LOG="https://logs.opendaylight.org/releng/vex-yul-odl-jenkins-1/${GERRIT_PROJECT}-distribution-check-${DIST}/${ODL_BUILD_JOB_NUM}/console.log.gz"
20 NETVIRT_ARTIFACT_URL=$(curl --fail --compressed ${DISTRO_CHECK_CONSOLE_LOG} | grep 'BUNDLE_URL' | cut -d = -f 2)
21
22 echo -e "URL to artifact is\n\t$NETVIRT_ARTIFACT_URL"
23
24 echo "Downloading the artifact. This could take time..."
25 if ! wget -q -O $ODL_ZIP $NETVIRT_ARTIFACT_URL; then
26     echo "The artifact does not exist! Probably removed due to ODL Jenkins artifact retention policy."
27     echo "Use 'recheck' on the gerrit to get artifact rebuilt."
28     exit 1
29 fi
30
31 #TODO(trozet) remove this once odl-pipeline accepts zip files
32 echo "Converting artifact zip to tar.gz"
33 UNZIPPED_DIR=`dirname $(unzip -qql ${ODL_ZIP} | head -n1 | tr -s ' ' | cut -d' ' -f5-)`
34 unzip ${ODL_ZIP}
35 tar czf /tmp/${NETVIRT_ARTIFACT} ${UNZIPPED_DIR}
36
37 echo "Download complete"
38 ls -al /tmp/${NETVIRT_ARTIFACT}