Configure integration scripts to use Nexus proxy
[releng/builder.git] / jjb / integration / include-raw-integration-deploy-controller-offline.sh
1 # Create a script to run controller inside a dynamic jenkins slave
2 DISTRIBUTION="karaf"
3 CONTROLLERFEATURES="odl-integration-compatible-with-all"
4 CONTROLLERMEM="3072m"
5
6 NEXUSURL_PREFIX=${ODLNEXUSPROXY:-https://nexus.opendaylight.org}
7
8 if [ ${BUNDLEURL} == 'last' ]; then
9     NEXUSPATH="${NEXUSURL_PREFIX}/content/repositories/opendaylight.snapshot/org/opendaylight/integration/distribution-${DISTRIBUTION}"
10     # Extract the BUNDLEVERSION from the pom.xml
11     BUNDLEVERSION=`xpath pom.xml '/project/version/text()' 2> /dev/null`
12     echo "Bundle version is ${BUNDLEVERSION}"
13     # Acquire the timestamp information from maven-metadata.xml
14     wget ${NEXUSPATH}/${BUNDLEVERSION}/maven-metadata.xml
15     TIMESTAMP=`xpath maven-metadata.xml "//snapshotVersion[extension='zip'][1]/value/text()" 2>/dev/null`
16     echo "Nexus timestamp is ${TIMESTAMP}"
17     BUNDLEFOLDER="distribution-${DISTRIBUTION}-${BUNDLEVERSION}"
18     BUNDLE="distribution-${DISTRIBUTION}-${TIMESTAMP}.zip"
19     BUNDLEURL="${NEXUSPATH}/${BUNDLEVERSION}/${BUNDLE}"
20 else
21     BUNDLE="$(echo ${BUNDLEURL} | awk -F '/' '{ print $(NF) }')"
22     echo "Finding out Bundle folder..."
23     wget --no-verbose  ${BUNDLEURL}
24     BUNDLEFOLDER="$(unzip -qql ${BUNDLE} | head -n1 | tr -s ' ' | cut -d' ' -f5- | rev | cut -c 2- | rev)"
25     rm ${BUNDLE}
26 fi
27
28 echo "Distribution bundle URL is ${BUNDLEURL}"
29 echo "Distribution bundle is ${BUNDLE}"
30 echo "Distribution folder is ${BUNDLEFOLDER}"
31
32 echo "Downloading the distribution from ${BUNDLEURL}"
33 wget --no-verbose  ${BUNDLEURL}
34
35 echo "Extracting the new controller..."
36 unzip -q ${BUNDLE}
37
38 echo "Configuring the startup features..."
39 cd ${BUNDLEFOLDER}/etc
40 CFG=org.apache.karaf.features.cfg
41 cp ${CFG} ${CFG}.bak
42 cat ${CFG}.bak | sed "s/^featuresBoot=.*/featuresBoot=config,standard,region,package,kar,ssh,management,${CONTROLLERFEATURES}/" > ${CFG}.1
43 cat ${CFG}.1 | sed "s%mvn:org.opendaylight.integration/features-integration-index/${BUNDLEVERSION}/xml/features%mvn:org.opendaylight.integration/features-integration-index/${BUNDLEVERSION}/xml/features,mvn:org.opendaylight.integration/features-integration-test/${BUNDLEVERSION}/xml/features%" > ${CFG}
44 cat ${CFG}
45
46 echo "Configuring the log..."
47 LOG=org.ops4j.pax.logging.cfg
48 cp ${LOG} ${LOG}.bak
49 cat ${LOG}.bak | sed 's/log4j.appender.out.maxFileSize=1MB/log4j.appender.out.maxFileSize=20MB/' > ${LOG}
50 cat ${LOG}
51
52 echo "Configure the repos..."
53 REPO=org.ops4j.pax.url.mvn.cfg
54 cp ${REPO} ${REPO}.bak
55 cat ${REPO}.bak | sed '/http/d' | sed '$s/...$//'> ${REPO}
56 cat ${REPO}
57
58 echo "Configure max memory..."
59 MEM=setenv
60 cd ../bin
61 cp ${MEM} ${MEM}.bak
62 cat ${MEM}.bak | sed 's/JAVA_MAX_MEM="2048m"/JAVA_MAX_MEM="${CONTROLLERMEM}"/' > ${MEM}
63 cat ${MEM}
64
65 echo "Starting controller..."
66 ./start &
67
68 echo "sleeping for 20 seconds..."
69 sleep 20
70
71 echo "Check OSGi bundles..."
72 ./client "feature:install ${CONTROLLERFEATURES}" || echo $? > ${WORKSPACE}/error.txt
73
74 echo "Fetching Karaf log"
75 cd ${WORKSPACE}
76 cp ${BUNDLEFOLDER}/data/log/karaf.log .
77
78 echo "Exit with error"
79 if [ `cat error.txt` -ne 0 ]; then
80     echo "Failed to deploy offline"
81     exit 1
82 fi
83
84 # vim: ts=4 sw=4 sts=4 et ft=sh :
85