Skip to content

Commit

Permalink
Merge pull request #212 from codylane/master
Browse files Browse the repository at this point in the history
bugfix for jenkins/helper_functions. Fixes incorrect homedir for jenk…
  • Loading branch information
codylane authored Nov 14, 2019
2 parents 9e07886 + 49c33fc commit 7b5a0ef
Showing 1 changed file with 47 additions and 5 deletions.
52 changes: 47 additions & 5 deletions jenkins/helper_functions
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ RVM_HOME_DIR="${RVM_HOME_DIR:-${HOME}/.rvm/scripts/rvm}"

VAGRANT_TEST_ISSUE="${VAGRANT_TEST_ISSUE:-180}"


err() {

echo "ERR: $* exiting" >&2

reset_docker_perms || true

exit 1

}
Expand Down Expand Up @@ -54,6 +56,8 @@ enable_rbenv_ruby() {

eval "$(rbenv init -)"

rbenv_install "${DEFAULT_RVM_RUBY}"

if [ -n "${persist}" ]; then

echo "${DEFAULT_RVM_RUBY}" > .ruby-version
Expand All @@ -66,6 +70,12 @@ enable_rbenv_ruby() {

}

rbenv_install() {

rbenv versions | grep -q "${1}" || rbenv install "${1}"

}

vagrant_cmd() {

bundle_exec vagrant $@
Expand All @@ -75,6 +85,9 @@ vagrant_cmd() {

install_gems() {

command -v bundle >>/dev/null 2>&1 || gem install bundler --no-doc
command -v rake >>/dev/null 2>&1 || gem install rake --no-doc

gem update --system --no-doc || err "Updating system gems"

rm -f Gemfile.lock
Expand All @@ -92,14 +105,20 @@ install_from_gemfile() {

run_all_tests() {

set -e

vagrant_cmd status
bundle_exec rake spec

set +e

}


setup_test_env() {

set -e

whoami
env

Expand All @@ -119,18 +138,20 @@ setup_test_env() {

reset_docker_perms

set +e

}


reset_docker_perms() {

sudo chmod 0770 "$(readlink /var/run/docker.sock)"
[ -L /var/run/docker.sock ] && sudo chmod 0770 "$(readlink /var/run/docker.sock)" || true

}

update_docker_perms() {

sudo chmod 6770 "$(readlink /var/run/docker.sock)"
[ -L /var/run/docker.sock ] && sudo chmod 6770 "$(readlink /var/run/docker.sock)" || true

}

Expand All @@ -148,13 +169,34 @@ is_container_running() {


initialize() {
reset_docker_perms

OS_TYPE="$(uname -s 2>>/dev/null)"

case "${OS_TYPE}" in

[ -f /Users/jenkins/.bash_profile ] && . /Users/jenkins/.bash_profile || true
[ -f /Users/jenkins/.bashrc ] && . /Users/jenkins/.bashrc || true
Darwin)
HOME_DIR_PREFIX="/Users"
;;

*)
HOME_DIR_PREFIX="/home"
;;

esac

[ -f ${HOME_DIR_PREFIX}/jenkins/.bash_profile ] && . ${HOME_DIR_PREFIX}/jenkins/.bash_profile || true
[ -f ${HOME_DIR_PREFIX}/jenkins/.bashrc ] && . ${HOME_DIR_PREFIX}/jenkins/.bashrc || true

command -v rvm >>/dev/null 2>&1 && enable_rvm_ruby "${DEFAULT_RVM_RUBY}" "persist" || true
command -v rbenv >>/dev/null 2>&1 && enable_rbenv_ruby "${DEFAULT_RVM_RUBY}" "persist" || true

command -v docker || err "Docker must be installed on this host."
command -v bsdtar || err "Please install bsdtar"

id
groups

CONTAINER_ID=$(is_container_running)
[ $? -ne 0 ] && docker rm -vf "${CONTAINER_ID}"

Expand Down

0 comments on commit 7b5a0ef

Please sign in to comment.