diff options
Diffstat (limited to 'node/build')
-rwxr-xr-x | node/build | 46 |
1 files changed, 24 insertions, 22 deletions
@@ -21,16 +21,34 @@ set -xe # We need ramdisk size when executing under root, but still don't want # to evaluate build config (== arbitrary code) as such. function get_ramdisk_size () { - sudo -E -H -u jenkins-build bash -es "$1" <<\EOF - export CONFIGURATION="$(echo "$1" | base64 -id)" - set -a - eval "$CONFIGURATION" - set +a + sudo -E -H -u jenkins-build bash -es <<\EOF + source /var/run/build-tools/build-config echo $RAMDISK_SIZE EOF } BUILD_SCRIPT_ROOT=$(readlink -f "$(dirname "${0}")/../build-scripts") +if ! $BUILD_SCRIPT_ROOT/../node/prepare_build_config.py "$2"; then + echo "Early exit due to build environment validation failure" + exit 1 +fi +# At this point, safely sourceable build config is in /var/run/build-tools/build-config +source /var/run/build-tools/build-config + +if [ -n "$BUILD_CONFIG_REPO" ]; then + echo "Fetching build config indirectly from git" + save_dir=$PWD + rm -rf /tmp/buildconf.$$ + mkdir -p /tmp/buildconf.$$ + cd /tmp/buildconf.$$ + git clone "$BUILD_CONFIG_REPO" + cd * + git checkout "$BUILD_CONFIG_BRANCH" + $BUILD_SCRIPT_ROOT/../node/prepare_build_config.py "$(cat "$BUILD_CONFIG_FILENAME")" + cd $save_dir + source /var/run/build-tools/build-config +fi + # Stopgap measure to cleanup environment on instances reused for different jobs mount | grep -E "^tmpfs on .+workspace/" | awk ' {print $3}' | xargs --no-run-if-empty -n1 umount @@ -66,26 +84,10 @@ cd build sudo -E -H -u jenkins-build bash -xes "${BUILD_SCRIPT_ROOT}" "$@" <<\EOF export BUILD_SCRIPT_ROOT="${1}" HOST="${2}" -export CONFIGURATION="$(echo "${3}" | base64 -id)" set -a -eval "$CONFIGURATION" +source /var/run/build-tools/build-config set +a -if [ -n "$BUILD_CONFIG_REPO" ]; then - echo "Fetching build config indirectly from git" - save_dir=$PWD - rm -rf /tmp/buildconf.$$ - mkdir -p /tmp/buildconf.$$ - cd /tmp/buildconf.$$ - git clone "$BUILD_CONFIG_REPO" - cd * - git checkout "$BUILD_CONFIG_BRANCH" - CONFIGURATION=$(cat "$BUILD_CONFIG_FILENAME") - cd $save_dir - set -a - eval $CONFIGURATION - set +a -fi # Backward compatibility with SCRIPT_NAME if [ -n "$SCRIPT_NAME" ]; then |