Allow specifying VPP repository in hc2vpp-integration job
[ci-management.git] / jjb / hc2vpp / include-raw-hc2vpp-integration-prebuild.sh
1 #!/bin/bash
2
3 set -ex
4
5 # Download the latest VPP java API package
6 URL="https://nexus.fd.io/service/local/artifact/maven/content"
7 VERSION="RELEASE"
8 GROUP="io.fd.vpp"
9 ARTIFACTS="vpp-api-java"
10
11 if [ "${OS}" == "ubuntu1404" ]; then
12     OS_PART="ubuntu.trusty.main"
13     PACKAGE="deb deb.md5"
14     CLASS="deb"
15 elif [ "${OS}" == "ubuntu1604" ]; then
16     OS_PART="ubuntu.xenial.main"
17     PACKAGE="deb deb.md5"
18     CLASS="deb"
19 elif [ "${OS}" == "centos7" ]; then
20     OS_PART="centos7"
21     PACKAGE="rpm rpm.md5"
22     CLASS=""
23 fi
24
25 # determine nexus repository to download VPP packages from
26 if [ -e vpp-stream ]; then
27     # override file is present, use the specified repo
28     STREAM_PART=`./vpp-stream`
29 else
30     if [ "${STREAM}" == "master" ]; then
31         # use the newest master
32         STREAM_PART=".master"
33     else
34         # use stable version from branch
35         STREAM_PART=".stable.${STREAM}"
36     fi
37 fi
38
39 REPO="fd.io${STREAM_PART}.${OS_PART}"
40
41 for ART in ${ARTIFACTS}; do
42     for PAC in ${PACKAGE}; do
43         curl "${URL}?r=${REPO}&g=${GROUP}&a=${ART}&p=${PAC}&v=${VERSION}&c=${CLASS}" -O -J || exit
44     done
45 done
46
47 # verify downloaded package
48 if [ "${OS}" == "centos7" ]; then
49     FILES=*.rpm
50 else
51     FILES=*.deb
52 fi
53
54 for FILE in ${FILES}; do
55     echo " "${FILE} >> ${FILE}.md5
56 done
57 for MD5FILE in *.md5; do
58     md5sum -c ${MD5FILE} || exit
59     rm ${MD5FILE}
60 done
61
62 # install vpp-api-java, this extracts jvpp .jar files into usr/share/java
63 if [ "${OS}" == "centos7" ]; then
64     sudo rpm --nodeps --install vpp-api-java*
65 else
66     sudo dpkg --ignore-depends=vpp --install vpp-api-java*
67 fi
68 rm vpp-api-java*
69
70 # install jvpp jars into maven repo, so that maven picks them up when building hc2vpp
71 version=`./jvpp-version`
72
73 current_dir=`pwd`
74 cd /usr/share/java
75
76 for item in jvpp*.jar; do
77     # Example filename: jvpp-registry-17.01-20161206.125556-1.jar
78     # ArtifactId = jvpp-registry
79     # Version = 17.01
80     basefile=$(basename -s .jar "$item")
81     artifactId=$(echo "$basefile" | cut -d '-' -f 1-2)
82     mvn install:install-file -Dfile=${item} -DgroupId=io.fd.vpp -DartifactId=${artifactId} -Dversion=${version} -Dpackaging=jar -Dmaven.repo.local=/tmp/r -Dorg.ops4j.pax.url.mvn.localRepository=/tmp/r
83 done
84
85 cd ${current_dir}