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
21 if [ -z ${OVSTAG+1} ]; then
27 export DATE=`date +%Y-%m-%d`
29 export BUILD_BASE=$WORKSPACE/build
33 if [ ! -d $BUILD_BASE ]
36 if [ ! -f $BUILD_BASE/config ]; then
37 touch $BUILd_BASE/config
41 export PATH=$PATH:$WORKSPACE/ci:$BUILD_BASE
43 source $BUILD_BASE/config
46 export TOPDIR=$BUILD_BASE
50 export TMP_RELEASE_DIR=$TOPDIR/release
51 export CACHE_DIR=$TOPDIR/cache
52 export TMPDIR=$TOPDIR/scratch
53 export RPMDIR=$TOPDIR/rpmbuild
55 echo "--------------------------------------------------"
56 echo "Build OVS RPM from upstream git $TAG"
59 mkdir -p $RPMDIR/BUILD
61 mkdir -p $RPMDIR/SOURCES
62 mkdir -p $RPMDIR/SPECS
63 mkdir -p $RPMDIR/SRPMS
65 if [ ! -d $TMP_RELEASE_DIR ]
67 mkdir -p $TMP_RELEASE_DIR
70 # Centos build server should support the following build prerequisites
72 # yum install gcc make python-devel openssl-devel kernel-devel graphviz \
73 # kernel-debug-devel autoconf automake rpm-build redhat-rpm-config \
85 echo "---------------------"
86 echo "Clone git repo $TAG"
88 git clone https://github.com/openvswitch/ovs.git
91 echo "--------------------"
92 echo "Checkout OVS $TAG"
94 if [[ ! "$TAG" =~ "master" ]]; then
99 echo "--------------------"
104 # Get version for master
106 echo "--------------------"
107 echo "Get OVS version for $TAG"
109 if [[ "$TAG" =~ "master" ]]; then
110 v=$($TMPDIR/ovs/utilities/ovs-vsctl --version | head -1 | cut -d' ' -f4)
113 export VERSION=${TAG:1}
116 echo "--------------------"
117 echo "OVS version is $VERSION"
119 echo "--------------------"
120 echo "Make OVS distribution $TAG"
127 cp openvswitch-$VERSION.tar.gz $TOPDIR/rpmbuild/SOURCES
128 cp openvswitch-$VERSION.tar.gz $TMPDIR
131 tar -xzf openvswitch-$VERSION.tar.gz
133 cd $TMPDIR/openvswitch-$VERSION
136 echo "--------------------"
140 if [ ! -z ${NOCHECK+1} ]; then
141 # Build RPM without checks
143 rpmbuild -bb --define "_topdir `echo $RPMDIR`" --without check rhel/openvswitch.spec
145 rpmbuild -bb --define "_topdir `echo $RPMDIR`" rhel/openvswitch.spec
148 # Once build is done copy product to artifactory.
150 echo "---------------------------------------"
151 echo "Copy RPM into $TMP_RELEASE_DIR"
153 cp $RPMDIR/RPMS/x86_64/*.rpm $TMP_RELEASE_DIR
157 echo "---------------------------------------"
158 echo "Cleanup $TMP_RELEASE_DIR"
170 if [ ! -z ${JENKINS+1} ]; then