2 ##############################################################################
3 # Copyright (c) 2015 Red Hat Inc. and others.
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
11 # Check to verify that I am being run by Jenkins CI.
13 if [ -z ${WORKSPACE+1} ]; then
14 # We are not being run by Jenkins.
15 export WORKSPACE=$HOME/opnfv/ovsnfv
19 if [ -z ${OVSTAG+1} ]; then
25 export DATE=`date +%Y-%m-%d`
27 export BUILD_BASE=$WORKSPACE/build
31 if [ ! -d $BUILD_BASE ]
36 if [ ! -f $BUILD_BASE/config ]; then
37 touch $BUILD_BASE/config
40 export PATH=$PATH:$WORKSPACE/ci:$BUILD_BASE
42 source $BUILD_BASE/config
45 export TOPDIR=$BUILD_BASE
49 export TMP_RELEASE_DIR=$TOPDIR/release
50 export CACHE_DIR=$TOPDIR/cache
51 export TMPDIR=$TOPDIR/scratch
52 export RPMDIR=$TOPDIR/rpmbuild
54 echo "--------------------------------------------------"
55 echo "Build OVS RPM from upstream git $TAG"
59 mkdir -p $RPMDIR/SOURCES
60 mkdir -p $RPMDIR/SPECS
61 mkdir -p $RPMDIR/SRPMS
63 if [ ! -d $TMP_RELEASE_DIR ]
65 mkdir -p $TMP_RELEASE_DIR
68 # Centos build server should support the following build prerequisites
70 # yum install gcc make python-devel openssl-devel kernel-devel graphviz \
71 # kernel-debug-devel autoconf automake rpm-build redhat-rpm-config \
83 echo "---------------------"
84 echo "Clone git repo $TAG"
86 git clone https://github.com/openvswitch/ovs.git
89 echo "--------------------"
90 echo "Checkout OVS $TAG"
92 if [[ ! "$TAG" =~ "master" ]]; then
97 echo "--------------------"
102 # Get version for master
104 echo "--------------------"
105 echo "Get OVS version for $TAG"
107 if [[ "$TAG" =~ "master" ]]; then
108 v=$($TMPDIR/ovs/utilities/ovs-vsctl --version | head -1 | cut -d' ' -f4)
111 export VERSION=${TAG:1}
114 echo "--------------------"
115 echo "OVS version is $VERSION"
117 echo "--------------------"
118 echo "Make OVS distribution $TAG"
125 cp openvswitch-$VERSION.tar.gz $TOPDIR/rpmbuild/SOURCES
126 cp openvswitch-$VERSION.tar.gz $TMPDIR
129 tar -xzf openvswitch-$VERSION.tar.gz
131 cd $TMPDIR/openvswitch-$VERSION
134 echo "--------------------"
138 if [ ! -z ${NOCHECK+1} ]; then
139 # Build RPM without checks
141 rpmbuild -bb --define "_topdir `echo $RPMDIR`" --without check rhel/openvswitch.spec
143 rpmbuild -bb --define "_topdir `echo $RPMDIR`" rhel/openvswitch.spec
146 # Once build is done copy product to artifactory.
148 echo "---------------------------------------"
149 echo "Copy RPM into $TMP_RELEASE_DIR"
151 cp $RPMDIR/RPMS/x86_64/*.rpm $TMP_RELEASE_DIR
155 echo "---------------------------------------"
156 echo "Cleanup $TMP_RELEASE_DIR"
168 if [[ "$JOB_NAME" =~ "daily" ]]; then