2013-06-24 13:41:48 +02:00
# Copyright (c) Citrix Systems Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms,
# with or without modification, are permitted provided
# that the following conditions are met:
#
# * Redistributions of source code must retain the above
# copyright notice, this list of conditions and the
# following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the
# following disclaimer in the documentation and/or other
# materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#==============================================================
#Micro version override - please keep at the top of the script
#==============================================================
#Set and uncomment this to override the 3rd value of the product number
#normally fetched from branding
#
#PRODUCT_MICRO_VERSION_OVERRIDE=<My override value here>
#this is the XenServer branch we're building; change this when making a new branch
if [ -n " ${ DEBUG +xxx } " ] ;
then
2015-07-22 10:36:15 +02:00
set -x
2013-06-24 13:41:48 +02:00
fi
# that's the code to get the branch name of the repository
SOURCE = " ${ BASH_SOURCE [0] } "
2013-07-30 13:42:43 +02:00
XENADMIN_DIR = " $( cd -P " $( dirname " ${ BASH_SOURCE [0] } " ) /.. " && pwd ) "
2013-06-24 13:41:48 +02:00
DIR = " $( dirname " $SOURCE " ) "
while [ -h " $SOURCE " ]
do
SOURCE = " $( readlink " $SOURCE " ) "
[ [ $SOURCE != /* ] ] && SOURCE = " $DIR / $SOURCE "
DIR = " $( cd -P " $( dirname " $SOURCE " ) " && pwd ) "
done
DIR = " $( cd -P " $( dirname " $SOURCE " ) " && pwd ) "
if [ -z " ${ JOB_NAME +xxx } " ]
then
JOB_NAME = "devbuild"
2015-07-22 10:36:15 +02:00
echo " WARN: JOB_NAME env var not set, we will use ${ JOB_NAME } "
2013-06-24 13:41:48 +02:00
fi
if [ -z " ${ BUILD_NUMBER +xxx } " ]
then
BUILD_NUMBER = "0"
2015-07-22 10:36:15 +02:00
echo " WARN: BUILD_NUMBER env var not set, we will use ${ BUILD_NUMBER } "
2013-06-24 13:41:48 +02:00
fi
if [ -z " ${ BUILD_ID +xxx } " ]
then
BUILD_ID = $( date +"%Y-%m-%d_%H-%M-%S" )
2015-07-22 10:36:15 +02:00
echo " WARN: BUILD_ID env var not set, we will use ${ BUILD_ID } "
2013-06-24 13:41:48 +02:00
fi
if [ -z " ${ BUILD_URL +xxx } " ]
then
BUILD_URL = "n/a"
2015-07-22 10:36:15 +02:00
echo "WARN: BUILD_URL env var not set, we will use 'n/a'"
2013-06-24 13:41:48 +02:00
fi
2013-07-30 13:42:43 +02:00
if [ -d " $DIR /../.git " ]
then
if [ -z " ${ GIT_COMMIT - } " ]
then
get_REVISION = "none"
2015-07-22 10:36:15 +02:00
echo "WARN: GIT_COMMIT env var not set, we will use 'none'"
2013-07-30 13:42:43 +02:00
else
get_REVISION = " ${ GIT_COMMIT } "
fi
XS_BRANCH = ` cd $DIR ; git config --get remote.origin.url| sed -e 's@.*carbon/\(.*\)/xenadmin.git.*@\1@' `
2015-07-21 17:19:25 +02:00
if [ [ $XS_BRANCH = = *"/" * ] ]
then
XS_BRANCH = "trunk"
2015-07-22 10:36:15 +02:00
echo " WARN: Failed to detect XS_BRANCH we will fallback to ${ XS_BRANCH } "
2015-07-21 17:19:25 +02:00
fi
2013-07-30 13:42:43 +02:00
else
if [ -z " ${ MERCURIAL_REVISION +xxx } " ]
then
MERCURIAL_REVISION = "none"
2015-07-22 10:36:15 +02:00
echo " WARN: MERCURIAL_REVISION env var not set, we will use $MERCURIAL_REVISION "
2013-07-30 13:42:43 +02:00
fi
get_REVISION = ${ MERCURIAL_REVISION }
XS_BRANCH = ` cd $DIR ; hg showconfig paths.default| sed -e 's@.*carbon/\(.*\)/xenadmin.hg.*@\1@' `
2013-06-24 13:41:48 +02:00
fi
2013-07-30 13:42:43 +02:00
if [ -z " ${ XS_BRANCH +xxx } " ]
2013-07-02 14:30:31 +02:00
then
2015-07-22 10:36:15 +02:00
echo "ERROR: Failed to detect the branch, stopping here because this would break things much later."
2013-07-30 13:42:43 +02:00
exit 1
2013-07-02 14:30:31 +02:00
else
2015-07-22 10:36:15 +02:00
echo " INFO: Running on branch: $XS_BRANCH "
2013-07-02 14:30:31 +02:00
fi
2013-06-24 13:41:48 +02:00
#rename Jenkins environment variables to distinguish them from ours; remember to use them as get only
get_JOB_NAME = ${ JOB_NAME }
get_BUILD_NUMBER = ${ BUILD_NUMBER }
get_BUILD_ID = ${ BUILD_ID }
get_BUILD_URL = ${ BUILD_URL }
#do everything in place as jenkins runs a clean build, i.e. will delete previous artifacts on starting
if [ -z " ${ WORKSPACE +xxx } " ]
then
DIR = " $( cd -P " $( dirname " ${ BASH_SOURCE [0] } " ) /../.. " && pwd ) "
2015-06-30 13:41:11 +02:00
WORKSPACE = " ${ DIR } "
2015-07-22 10:36:15 +02:00
echo " WARN: WORKSPACE env var not set, we will use ${ WORKSPACE } "
2013-06-24 13:41:48 +02:00
fi
if which cygpath >/dev/null; then
ROOT = $( cygpath -u " ${ WORKSPACE } " )
else
ROOT = ${ WORKSPACE }
fi
2015-07-22 10:36:15 +02:00
echo " INFO: Workspace located in: $ROOT "
2013-07-30 13:42:43 +02:00
REPO = ${ XENADMIN_DIR }
2013-06-24 13:41:48 +02:00
REF_REPO = ${ ROOT } /xenadmin-ref.hg
2016-01-08 11:50:40 +01:00
BRAND_REPO = ${ ROOT } /xenadmin-branding
2013-06-24 13:41:48 +02:00
SCRATCH_DIR = ${ ROOT } /scratch
OUTPUT_DIR = ${ ROOT } /output
2015-06-22 16:03:32 +02:00
TEST_DIR = ${ ROOT } /tmp
mkdir -p ${ TEST_DIR }
2013-06-24 13:41:48 +02:00
BUILD_ARCHIVE = ${ ROOT } /../builds/${ get_BUILD_ID } /archive
2015-01-19 17:39:21 +01:00
SECURE_BUILD_ARCHIVE_UNC = //10.80.13.10/distfiles/distfiles/windowsbuilds/WindowsBuilds/$get_JOB_NAME /$BUILD_NUMBER /
2015-07-13 21:52:41 +02:00
XENCENTER_LOGDIR = " ${ ROOT } /log "
mkdir -p ${ XENCENTER_LOGDIR }
2013-06-24 13:41:48 +02:00
2014-10-10 17:20:00 +02:00
# WEB_LIB is where the libraries stored in /usr/groups/linux/distfiles are exposed
#WEB_LATEST_BUILD is where the current build will retrieve some of its dependendencies,
2013-06-24 13:41:48 +02:00
#i.e. XenCenterOvf, version number, branding info and XenServer.NET;
#use xe-phase-2-latest to ensure we use a build where phases 1 and 2 have succeeded
2014-10-10 17:20:00 +02:00
if [ " ${ BUILD_KIND : + $BUILD_KIND } " = production ]
then
WEB_LIB = "http://admin/linux/distfiles/windows-build"
WEB_LATEST_BUILD = " http://admin/builds/carbon/ ${ XS_BRANCH } /xe-phase-2-latest "
else
WEB_LIB = "http://files.uk.xensource.com/linux/distfiles/windows-build"
WEB_LATEST_BUILD = " http://www.uk.xensource.com/carbon/ ${ XS_BRANCH } /xe-phase-2-latest "
fi
2013-06-24 13:41:48 +02:00
WEB_XE_PHASE_1 = ${ WEB_LATEST_BUILD } /xe-phase-1
WEB_XE_PHASE_2 = ${ WEB_LATEST_BUILD } /xe-phase-2
2015-01-19 17:39:21 +01:00
#this is where the build will find stuff from the latest dotnet-packages build
2015-07-13 21:52:41 +02:00
WEB_DOTNET = " http://tocco.do.citrite.net:8080/job/carbon_ ${ XS_BRANCH } _dotnet-packages/lastSuccessfulBuild/artifact "
2013-06-24 13:41:48 +02:00
2014-10-10 17:20:00 +02:00
# used to copy results out of the secure build enclave
BUILD_TOOLS_REPO = git://admin/git/closed/windows/buildtools.git
BUILD_TOOLS = ${ SCRATCH_DIR } /buildtools.git
STORE_FILES = ${ BUILD_TOOLS } /scripts/storefiles.py
2016-02-11 23:18:06 +01:00
# this is where the build will find the RPU hotfixes
WEB_HOTFIXES = https://repo.citrite.net/builds/xs/hotfixes/${ XS_BRANCH }
2013-06-24 13:41:48 +02:00
#check there are xenserver builds on this branch before proceeding
2015-07-13 21:52:41 +02:00
wget -T 10 -N -q --spider ${ WEB_XE_PHASE_1 } /globals || { echo 'FATAL: Unable to locate globals, xenadmin cannot be built if there is no succesfull build of xenserver published for the same branch.' ; exit 1; }
2013-06-24 13:41:48 +02:00