summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSeth Chisamore <schisamo@getchef.com>2014-06-11 13:05:10 -0500
committerSeth Chisamore <schisamo@getchef.com>2014-06-11 14:27:05 -0500
commitf1c220afd074e927fe46be096dbedca14729879b (patch)
tree3840dc95ea0b63debfe51cc17b78d8b643d91b12
parent2e0f0dba57d0e9a6ccb8a78ff8b2706558c2d7fe (diff)
downloadchef-schisamo/ci-execute-with-sudo.tar.gz
Execute tests with elevated privilegesschisamo/ci-execute-with-sudo
-rwxr-xr-xci/jenkins_run_tests.sh8
1 files changed, 6 insertions, 2 deletions
diff --git a/ci/jenkins_run_tests.sh b/ci/jenkins_run_tests.sh
index ba38bf2da4..fd14e317cd 100755
--- a/ci/jenkins_run_tests.sh
+++ b/ci/jenkins_run_tests.sh
@@ -5,8 +5,12 @@ export PATH=$PATH:/usr/local/bin
ruby -v;
# remove the Gemfile.lock and try again if bundler fails.
# This should take care of Gemfile changes that result in "bad" bundles without forcing us to rebundle every time
-bundle install --without docgen --path vendor/bundle || ( rm Gemfile.lock && bundle install --path vendor/bundle )
-bundle exec rspec -r rspec_junit_formatter -f RspecJunitFormatter -o test.xml -f documentation spec;
+bundle install --binstubs --without docgen --path vendor/bundle || ( rm Gemfile.lock && bundle install --binstubs --path vendor/bundle )
+# preserve the environment and $PATH of the `jenkins` user
+sudo -E bash -c "export PATH=$PATH && bin/rspec -r rspec_junit_formatter -f RspecJunitFormatter -o test.xml -f documentation spec"
+# Ensure Jenkins can clean this file up
+sudo chown ${USER-`whoami`} test.xml
+
RSPEC_RETURNCODE=$?
# exit with the result of running rspec