summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2012-10-05 13:43:44 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2012-10-05 13:43:44 +0300
commit672c991288b1eaaba6440e52f7cabd45662ac1de (patch)
treeef9843e814007ff7031597a50ec5e0d4b1ce0dbc /lib
parentf13422976258dbcc6ccf6dffb54d7b76ecdb89f9 (diff)
downloadgitlab-ci-672c991288b1eaaba6440e52f7cabd45662ac1de.tar.gz
Change the call we use
Diffstat (limited to 'lib')
-rw-r--r--lib/runner.rb49
1 files changed, 34 insertions, 15 deletions
diff --git a/lib/runner.rb b/lib/runner.rb
index ba5a213..6d20c9f 100644
--- a/lib/runner.rb
+++ b/lib/runner.rb
@@ -1,3 +1,4 @@
+require 'open3'
class Runner
attr_accessor :project, :build
@queue = :runner
@@ -15,21 +16,39 @@ class Runner
trace = ''
path = project.path
commands = project.scripts
- commands.each_line do |line|
- line = line.strip
- trace << "\n"
- cmd = "cd #{path} && " + line
- trace << cmd
- trace << "\n"
- trace << `#{cmd}`
-
- unless $?.exitstatus == 0
- build.update_attributes(
- trace: trace,
- status: 'fail'
- )
-
- return false
+
+ Dir.chdir(path) do
+ commands.each_line do |line|
+ line = line.strip
+ trace << "\n"
+ cmd = line
+ trace << cmd
+ trace << "\n"
+
+ vars = {
+ "BUNDLE_GEMFILE" => nil,
+ "BUNDLE_BIN_PATH" => nil,
+ "RUBYOPT" => nil,
+ "rvm_" => nil,
+ "RACK_ENV" => nil,
+ "RAILS_ENV" => nil,
+ "PWD" => path
+ }
+ options = {
+ :chdir => path
+ }
+
+ stdin, stdout, stderr = Open3.popen3(vars, cmd, options)
+ trace << stdout.read
+
+ unless $?.exitstatus == 0
+ build.update_attributes(
+ trace: trace,
+ status: 'fail'
+ )
+
+ return false
+ end
end
end