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 087d8ae50b1..5c7a61d3397 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