Commit fe5d30ab authored by Stefan Wolfsheimer's avatar Stefan Wolfsheimer
Browse files

CI: added additional target system, changed directory structure

parent 3158eec1
pipeline
{
agent any
environment {
BUILD_NUMBER = "${env.BUILD_NUMBER}"
GIT_URL = "${env.GIT_URL}"
GIT_BRANCH = "${env.GIT_BRANCH}"
YUM_SERVER = 'software@software.irodspoc-sara.surf-hosted.nl'
SSH_OPTIONS = '-oStrictHostKeyChecking=no'
}
stages
{
......@@ -16,7 +23,7 @@ pipeline
echo '----------------------------'
echo 'Building against iRODS 4.2.6'
echo '----------------------------'
sh './ci/build.sh centos7_4_2_6'
sh './ci/build.sh centos7_4_2_6 --build ${BUILD_NUMBER} --url ${GIT_URL} --branch ${GIT_BRANCH}'
}
}
......@@ -32,7 +39,7 @@ pipeline
echo '-----------------------------'
echo 'Building against iRODS 4.1.12'
echo '-----------------------------'
sh './ci/build.sh centos7_4_1_12'
sh './ci/build.sh centos7_4_1_12 --build ${BUILD_NUMBER} --url ${GIT_URL} --branch ${GIT_BRANCH}'
}
}
......@@ -43,7 +50,7 @@ pipeline
echo '----------------------------'
echo 'Testing against iRODS 4.2.6 '
echo '----------------------------'
sh './ci/test.sh centos7_4_2_6'
sh './ci/test.sh centos7_4_2_6 --build ${BUILD_NUMBER} --url ${GIT_URL} --branch ${GIT_BRANCH}'
}
}
stage('Test_4_1_12')
......@@ -53,16 +60,27 @@ pipeline
echo '-----------------------------'
echo 'Testing against iRODS 4.1.12'
echo '-----------------------------'
sh './ci/test.sh centos7_4_1_12'
sh './ci/test.sh centos7_4_1_12 --build ${BUILD_NUMBER} --url ${GIT_URL} --branch ${GIT_BRANCH}'
}
}
stage('Deploy')
stage('Deploy_4_1_12')
{
steps
{
echo 'Deploying....'
echo '------------------------------'
echo 'Deploying.'
sh './ci/deploy.sh centos7_4_1_12 --build ${BUILD_NUMBER} --url ${GIT_URL} --branch ${GIT_BRANCH}'
}
}
}
stage('Deploy_4_2_6')
{
steps
{
echo '------------------------------'
echo 'Deploying.'
sh './ci/deploy.sh centos7_4_2_6 --build ${BUILD_NUMBER} --url ${GIT_URL} --branch ${GIT_BRANCH}'
}
}
}
}
\ No newline at end of file
#!/bin/bash
set -x
set -e
BUILD=$1
if [[ -z "$BUILD" ]]
then
BUILD=0
fi
chown irods /var/lib/irods
sudo -u irods cp -r /build /src/B2SAFE-core
cd /src/B2SAFE-core/packaging
sudo -u irods ./create_rpm_package.sh
sudo -u irods ./create_rpm_package.sh $BUILD
chmod a+w /var/lib/irods/rpmbuild/RPMS/noarch/*.rpm
......
#!/bin/bash
set -x
set -e
VERSION=$1
if [[ -z "$VERSION" ]]
then
VERSION=centos7_4_2_6
fi
VERSION=centos7_4_2_6
CLEANUP="yes"
BUILD=0
GIT_BRANCH=""
GIT_URL=""
IRODS_VERSION=$( echo $VERSION | awk 'BEGIN{ FS="_"; }{ print $2"."$3"."$4; }' )
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
"--nocleanup")
CLEANUP="no"
shift
;;
"--url")
shift
GIT_URL=$1
shift
;;
"--branch")
shift
GIT_BRANCH=$1
shift
;;
"--build")
shift
BUILD=$1
shift
;;
*)
VERSION=$1
shift
;;
esac
done
cleanup () {
exit_code=$?
......@@ -16,12 +42,22 @@ cleanup () {
exit $exit_code
}
set -x
set -e
trap cleanup EXIT ERR INT TERM
mkdir -p ci/RPMS/Centos/7/irods-${IRODS_VERSION}
source $(cd `dirname "${BASH_SOURCE[0]}"` && pwd)/version.sh
RPM_PACKAGE=`rpm_package $BUILD `
IRODS_VERSION=`irods_version $VERSION`
REPO_NAME=`repo_name $VERSION $GIT_URL $GIT_BRANCH `
mkdir -p ci/RPMS/Centos/7/${REPO_NAME}
docker-compose -f ci/${VERSION}/docker-compose.yml build
docker-compose -f ci/${VERSION}/docker-compose.yml up -d
docker exec ${VERSION}_icat_1 /app/create_rpm.sh
docker exec ${VERSION}_icat_1 bash -c "set -x; set -e; cp /var/lib/irods/rpmbuild/RPMS/noarch/*.rpm /build/ci/RPMS/Centos/7/irods-${IRODS_VERSION};"
docker exec ${VERSION}_icat_1 /app/create_rpm.sh $BUILD
docker exec ${VERSION}_icat_1 bash -c "set -x; set -e; cp /var/lib/irods/rpmbuild/RPMS/noarch/${RPM_PACKAGE} /build/ci/RPMS/Centos/7/${REPO_NAME};"
#!/bin/bash
echo $1
VERSION=centos7_4_2_6
CLEANUP="yes"
BUILD=0
GIT_BRANCH=""
GIT_URL=""
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
"--nocleanup")
CLEANUP="no"
shift
;;
"--url")
shift
GIT_URL=$1
shift
;;
"--branch")
shift
GIT_BRANCH=$1
shift
;;
"--build")
shift
BUILD=$1
shift
;;
*)
VERSION=$1
shift
;;
esac
done
source $(cd `dirname "${BASH_SOURCE[0]}"` && pwd)/version.sh
RPM_PACKAGE=`rpm_package $BUILD `
IRODS_VERSION=`irods_version $VERSION`
REPO_NAME=`repo_name $VERSION $GIT_URL $GIT_BRANCH `
set -e
set -x
ssh $SSH_OPTIONS $YUM_SERVER "mkdir -p /repos/CentOS/7/${REPO_NAME}/Packages/"
scp $SSH_OPTIONS ./ci/RPMS/Centos/7/${REPO_NAME}/${RPM_PACKAGE} $YUM_SERVER:/repos/CentOS/7/${REPO_NAME}/Packages/
ssh $SSH_OPTIONS $YUM_SERVER createrepo --update /repos/CentOS/7/${REPO_NAME}
......@@ -3,6 +3,7 @@
# default version
VERSION=centos7_4_2_6
CLEANUP="yes"
BUILD=0
while [[ $# -gt 0 ]]
do
......@@ -12,6 +13,21 @@ do
CLEANUP="no"
shift
;;
"--url")
shift
GIT_URL=$1
shift
;;
"--branch")
shift
GIT_BRANCH=$1
shift
;;
"--build")
shift
BUILD=$1
shift
;;
*)
VERSION=$1
shift
......@@ -38,21 +54,20 @@ trap cleanup EXIT ERR INT TERM
docker-compose -f ci/${VERSION}/docker-compose.yml build
docker-compose -f ci/${VERSION}/docker-compose.yml up -d
# find directory where we are executing:
ABSOLUTE_PATH=$(cd `dirname "${BASH_SOURCE[0]}"` && pwd)
MAJOR_VERS=`grep "^\s*\*major_version" $ABSOLUTE_PATH/../rulebase/local.re | awk -F\" '{print $2}'`
MINOR_VERS=`grep "^\s*\*minor_version" $ABSOLUTE_PATH/../rulebase/local.re | awk -F\" '{print $2}'`
SUB_VERS=`grep "^\s*\*sub_version" $ABSOLUTE_PATH/../rulebase/local.re | awk -F\" '{print $2}'`
RPM_VERSION="${MAJOR_VERS}.${MINOR_VERS}-${SUB_VERS}"
set +x
source $(cd `dirname "${BASH_SOURCE[0]}"` && pwd)/version.sh
RPM_PACKAGE=`rpm_package $BUILD `
IRODS_VERSION=`irods_version $VERSION`
REPO_NAME=`repo_name $VERSION $GIT_URL $GIT_BRANCH `
EXEC="docker exec ${VERSION}_icat_1"
EXEC_IRODS="docker exec -u irods ${VERSION}_icat_1 "
set -x
# copy source tree
$EXEC cp -r /build /src/B2SAFE-core
# install RPM
$EXEC rpm -i /build/ci/RPMS/Centos/7/irods-${IRODS_VERSION}/irods-eudat-b2safe-${RPM_VERSION}.noarch.rpm
$EXEC rpm -i /build/ci/RPMS/Centos/7/${REPO_NAME}/${RPM_PACKAGE}
# copy configuration
if [ -e ~/secret ]
......
# ###############################################################
#
# extract the name of the RPM pacakge from source.
# The B2SAFE version number is extracted from rulebase/local.re
#
# usage:
# -----
# rpm {BUILD}
#
# return:
# irods-eudat-b2safe-${MAJOR_VERS}.${MINOR_VERS}.${SUB_VERS}-${BUILD}.noarch.rpm
#
# ###############################################################
function rpm_package()
{
local BUILD=$1
local ABSOLUTE_PATH=$(cd `dirname "${BASH_SOURCE[0]}"` && pwd)
local MAJOR_VERS=`grep "^\s*\*major_version" $ABSOLUTE_PATH/../rulebase/local.re | awk -F\" '{print $2}'`
local MINOR_VERS=`grep "^\s*\*minor_version" $ABSOLUTE_PATH/../rulebase/local.re | awk -F\" '{print $2}'`
local SUB_VERS=`grep "^\s*\*sub_version" $ABSOLUTE_PATH/../rulebase/local.re | awk -F\" '{print $2}'`
local VERSION="${MAJOR_VERS}.${MINOR_VERS}.${SUB_VERS}"
echo "irods-eudat-b2safe-${MAJOR_VERS}.${MINOR_VERS}.${SUB_VERS}-${BUILD}.noarch.rpm"
}
# ###############################################################
#
# usage:
# -----
# irods_version {OS_VERSION}_{IRODS_VERSION}
#
# return irods-version
#
# example:
# -------
# irods_version centos7_4_2_6
# > 4.2.6
#
# ###############################################################
function irods_version()
{
local VERSION=$1
echo $VERSION | awk 'BEGIN{ FS="_"; }{ print $2"."$3"."$4; }'
}
# ###############################################################
#
# usage:
# -----
# repo_name VERSION GIT_URL GIT_BRANCH
#
# VERSION: {OS_VERSION}_{IRODS_VERSION}, e.g. centos7_4_2_6
# GIT_URL: git repository
# GIT_BRANCH: name of the branch to be build
#
# return:
# ------
# irods-${IRODS_VERSION} (if user is EUDAT-B2SAFE and
# BRANCH is master)
# {USER}/{BRANCH}/irods-${IROS_VERSION} (otherwise)
#
# examples:
# --------
# soruce version.sh
# repo_name centos7_4_2_1 https://github.com/B2SAFE-CORE/B2SAFE-core master
# > irods-4.2.1
# repo_name centos7_4_2_1 https://github.com/B2SAFE-CORE/B2SAFE-core devel
# > B2SAFE-CORE/devel/irods-4.2.1
# repo_name centos7_4_2_1 https://github.com/stefan-wolfsheimer/B2SAFE-core master
# > stefan-wolfsheimer/master/irods-4.2.1
# ###############################################################
function repo_name()
{
local VERSION=$1
local GIT_URL=$2
local GIT_BRANCH=$3
local IRODS_VERSION=$( echo $VERSION | awk 'BEGIN{ FS="_"; }{ print $2"."$3"."$4; }' )
local USER=$( echo $GIT_URL | awk 'BEGIN{ FS="/"; }{ print $4; }' )
if [[ "${USER}" == "EUDAT-B2SAFE" ]] && [[ "${GIT_BRANCH}" == "master" ]]
then
echo irods-${IRODS_VERSION}
else
echo "${USER}/${GIT_BRANCH}/irods-${IRODS_VERSION}"
fi
}
......@@ -3,6 +3,12 @@
set -e
set -x
BUILD=$1
if [[ -z "$BUILD" ]]
then
BUILD=0
fi
USERNAME=`whoami`
if [ "$USERNAME" = "root" ]
......@@ -22,6 +28,8 @@ then
exit 1
fi
# create build directory's
mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
......@@ -40,9 +48,9 @@ ABSOLUTE_PATH=$(cd `dirname "${BASH_SOURCE[0]}"` && pwd)
MAJOR_VERS=`grep "^\s*\*major_version" $ABSOLUTE_PATH/../rulebase/local.re | awk -F\" '{print $2}'`
MINOR_VERS=`grep "^\s*\*minor_version" $ABSOLUTE_PATH/../rulebase/local.re | awk -F\" '{print $2}'`
SUB_VERS=`grep "^\s*\*sub_version" $ABSOLUTE_PATH/../rulebase/local.re | awk -F\" '{print $2}'`
VERSION="${MAJOR_VERS}.${MINOR_VERS}"
VERSION="${MAJOR_VERS}.${MINOR_VERS}.${SUB_VERS}"
# build rpm
rpmbuild -ba --define "_version $VERSION" --define "_release $SUB_VERS" irods-eudat-b2safe.spec
rpmbuild -ba --define "_version $VERSION" --define "_release $BUILD" irods-eudat-b2safe.spec
# done..
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment