1#!/bin/bash 2 3# Work around bug where devtoolset replaces sudo and breaks it. 4if [ -n "$DEVTOOLSET_VERSION" ]; then 5 export SUDO=/bin/sudo 6else 7 export SUDO=sudo 8fi 9 10as_jenkins() { 11 # NB: unsetting the environment variables works around a conda bug 12 # https://github.com/conda/conda/issues/6576 13 # NB: Pass on PATH and LD_LIBRARY_PATH to sudo invocation 14 # NB: This must be run from a directory that jenkins has access to, 15 # works around https://github.com/conda/conda-package-handling/pull/34 16 $SUDO -E -H -u jenkins env -u SUDO_UID -u SUDO_GID -u SUDO_COMMAND -u SUDO_USER env "PATH=$PATH" "LD_LIBRARY_PATH=$LD_LIBRARY_PATH" $* 17} 18 19conda_install() { 20 # Ensure that the install command don't upgrade/downgrade Python 21 # This should be called as 22 # conda_install pkg1 pkg2 ... [-c channel] 23 as_jenkins conda install -q -n py_$ANACONDA_PYTHON_VERSION -y python="$ANACONDA_PYTHON_VERSION" $* 24} 25 26conda_run() { 27 as_jenkins conda run -n py_$ANACONDA_PYTHON_VERSION --no-capture-output $* 28} 29 30pip_install() { 31 as_jenkins conda run -n py_$ANACONDA_PYTHON_VERSION pip install --progress-bar off $* 32} 33 34get_pinned_commit() { 35 cat "${1}".txt 36} 37