add jenkins build scripts

This commit is contained in:
Arne Morten Kvarving 2016-04-04 14:20:24 +02:00
parent a20da3a6d2
commit 7bc1ec7693
4 changed files with 124 additions and 0 deletions

21
jenkins/README.md Normal file
View File

@ -0,0 +1,21 @@
# opm-core jenkins build scripts:
**build-opm-core.sh**:
This is a helper script which contains a function for building,
testing and cloning opm-core and its dependencies.
**build.sh**:
This script will build dependencies, then build opm-core and execute its tests.
It is intended for post-merge builds of the master branch.
**build-pr.sh**:
This script will build dependencies, then build opm-core and execute its tests.
It inspects the $ghbPrBuildComment environmental variable to obtain a pull request
to use for ert, opm-common, opm-parser and opm-material (defaults to master)
and then builds $sha1 of opm-core. It is intended for pre-merge builds of pull requests.
You can optionally specify a given pull request to use for ert, opm-common,
opm-parser and opm-material through the trigger.
The trigger line needs to contain ert=<pull request number> and/or
opm-common=<pull request number> and/or opm-parser=<pull request number>
and/or opm-material=<pull request number>.

54
jenkins/build-opm-core.sh Executable file
View File

@ -0,0 +1,54 @@
#!/bin/bash
function build_opm_core {
# Build ERT
pushd .
mkdir -p $WORKSPACE/deps/ert
cd $WORKSPACE/deps/ert
git init .
git remote add origin https://github.com/Ensembles/ert
git fetch origin $ERT_REVISION:branch_to_build
test $? -eq 0 || exit 1
git checkout branch_to_build
popd
pushd .
mkdir -p serial/build-ert
cd serial/build-ert
cmake $WORKSPACE/deps/ert/devel -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$WORKSPACE/serial/install
cmake --build . --target install
test $? -eq 0 || exit 1
popd
# Build opm-common
pushd .
mkdir -p $WORKSPACE/deps/opm-common
cd $WORKSPACE/deps/opm-common
git init .
git remote add origin https://github.com/OPM/opm-common
git fetch origin $OPM_COMMON_REVISION:branch_to_build
test $? -eq 0 || exit 1
git checkout branch_to_build
popd
source $WORKSPACE/deps/opm-common/jenkins/build-opm-module.sh
pushd .
mkdir serial/build-opm-common
cd serial/build-opm-common
build_module "-DCMAKE_INSTALL_PREFIX=$WORKSPACE/serial/install" 0 $WORKSPACE/deps/opm-common
popd
# Build opm-parser
clone_and_build_module opm-parser "-DCMAKE_PREFIX_PATH=$WORKSPACE/serial/install -DCMAKE_INSTALL_PREFIX=$WORKSPACE/serial/install" $OPM_PARSER_REVISION $WORKSPACE/serial
# Build opm-material
clone_and_build_module opm-material "-DCMAKE_PREFIX_PATH=$WORKSPACE/serial/install -DCMAKE_INSTALL_PREFIX=$WORKSPACE/serial/install" $OPM_MATERIAL_REVISION $WORKSPACE/serial
# Build opm-core
pushd .
mkdir serial/build-opm-core
cd serial/build-opm-core
build_module "-DCMAKE_PREFIX_PATH=$WORKSPACE/serial/install" 1 $WORKSPACE
test $? -eq 0 || exit 1
popd
}

36
jenkins/build-pr.sh Executable file
View File

@ -0,0 +1,36 @@
#!/bin/bash
source `dirname $0`/build-opm-core.sh
ERT_REVISION=master
OPM_COMMON_REVISION=master
OPM_PARSER_REVISION=master
OPM_MATERIAL_REVISION=master
OPM_CORE_REVISION=$sha1
if grep -q "ert=" <<< $ghprbCommentBody
then
ERT_REVISION=pull/`echo $ghprbCommentBody | sed -r 's/.*ert=([0-9]+).*/\1/g'`/merge
fi
if grep -q "opm-common=" <<< $ghprbCommentBody
then
OPM_COMMON_REVISION=pull/`echo $ghprbCommentBody | sed -r 's/.*opm-common=([0-9]+).*/\1/g'`/merge
fi
if grep -q "opm-parser=" <<< $ghprbCommentBody
then
OPM_PARSER_REVISION=pull/`echo $ghprbCommentBody | sed -r 's/.*opm-parser=([0-9]+).*/\1/g'`/merge
fi
if grep -q "opm-material=" <<< $ghprbCommentBody
then
OPM_MATERIAL_REVISION=pull/`echo $ghprbCommentBody | sed -r 's/.*opm-material=([0-9]+).*/\1/g'`/merge
fi
echo "Building with ert=$ERT_REVISION opm-common=$OPM_COMMON_REVISION opm-parser=$OPM_PARSER_REVISION opm-material=$OPM_MATERIAL_REVISION opm-core=$OPM_CORE_REVISION"
build_opm_core
test $? -eq 0 || exit 1
cp serial/build-opm-core/testoutput.xml .

13
jenkins/build.sh Executable file
View File

@ -0,0 +1,13 @@
#!/bin/bash
source `dirname $0`/build-opm-core.sh
ERT_REVISION=master
OPM_COMMON_REVISION=master
OPM_PARSER_REVISION=master
OPM_MATERIAL_REVISION=master
build_opm_core
test $? -eq 0 || exit 1
cp serial/build-opm-core/testoutput.xml .