From f9ac23fc9ac156739f9bd0be2c55945d0512088b Mon Sep 17 00:00:00 2001 From: Nicolas Ruflin Date: Mon, 9 Oct 2017 18:36:00 +0200 Subject: [PATCH] Introduce jenkins_setup command to be reused (#5315) jenkins_setup in common.bash will also be used for the generator tests. --- dev-tools/common.bash | 18 ++++++++++++++++++ dev-tools/jenkins_ci.sh | 13 ++----------- dev-tools/jenkins_intake.sh | 15 +++------------ 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/dev-tools/common.bash b/dev-tools/common.bash index aff8ba6b662..07dbe7d8130 100644 --- a/dev-tools/common.bash +++ b/dev-tools/common.bash @@ -78,3 +78,21 @@ setup_go_path() { debug "GOPATH=${GOPATH}" } + +jenkins_setup() { + : "${HOME:?Need to set HOME to a non-empty value.}" + : "${WORKSPACE:?Need to set WORKSPACE to a non-empty value.}" + + # Setup Go. + export GOPATH=${WORKSPACE} + export PATH=${GOPATH}/bin:${PATH} + if [ -f ".go-version" ]; then + eval "$(gvm $(cat .go-version))" + else + eval "$(gvm 1.7.5)" + fi + + # Workaround for Python virtualenv path being too long. + export TEMP_PYTHON_ENV=$(mktemp -d) + export PYTHON_ENV="${TEMP_PYTHON_ENV}/python-env" +} diff --git a/dev-tools/jenkins_ci.sh b/dev-tools/jenkins_ci.sh index f89272ad437..9fe9de24c2b 100755 --- a/dev-tools/jenkins_ci.sh +++ b/dev-tools/jenkins_ci.sh @@ -12,18 +12,9 @@ if [ ! -d "$beat" ]; then exit fi -# Setup Go. -export GOPATH=${WORKSPACE} -export PATH=${GOPATH}/bin:${PATH} -if [ -f ".go-version" ]; then - eval "$(gvm $(cat .go-version))" -else - eval "$(gvm 1.7.5)" -fi +source ./dev-tools/common.bash -# Workaround for Python virtualenv path being too long. -TEMP_PYTHON_ENV=$(mktemp -d) -export PYTHON_ENV="${TEMP_PYTHON_ENV}/python-env" +jenkins_setup cleanup() { echo "Running cleanup..." diff --git a/dev-tools/jenkins_intake.sh b/dev-tools/jenkins_intake.sh index 9e23ea6a325..de8ec969ddb 100755 --- a/dev-tools/jenkins_intake.sh +++ b/dev-tools/jenkins_intake.sh @@ -4,18 +4,9 @@ set -euox pipefail : "${HOME:?Need to set HOME to a non-empty value.}" : "${WORKSPACE:?Need to set WORKSPACE to a non-empty value.}" -# Setup Go. -export GOPATH=${WORKSPACE} -export PATH=${GOPATH}/bin:${PATH} -if [ -f ".go-version" ]; then - eval "$(gvm $(cat .go-version))" -else - eval "$(gvm 1.7.5)" -fi +source ./dev-tools/common.bash -# Workaround for Python virtualenv path being too long. -TEMP_PYTHON_ENV=$(mktemp -d) -export PYTHON_ENV="${TEMP_PYTHON_ENV}/python-env" +jenkins_setup cleanup() { echo "Running cleanup..." @@ -24,4 +15,4 @@ cleanup() { } trap cleanup EXIT -make check \ No newline at end of file +make check