summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPatrick Helm <deradon87@gmail.com>2013-03-31 01:14:32 +0100
committerPatrick Helm <deradon87@gmail.com>2013-03-31 01:14:32 +0100
commite2100b0694e889b87353a11e4155aaeef0527bca (patch)
tree81e9bf3da064ae8241519b17ef8df9f3f310cab4 /lib
parent81465cc3b4095791a8258cf76ce0fe8deb23ccbd (diff)
downloadgitlab-ci-e2100b0694e889b87353a11e4155aaeef0527bca.tar.gz
Try to make Runner.rb transactional safe
Diffstat (limited to 'lib')
-rw-r--r--lib/runner.rb14
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/runner.rb b/lib/runner.rb
index c856d3a..8a07030 100644
--- a/lib/runner.rb
+++ b/lib/runner.rb
@@ -15,10 +15,12 @@ class Runner
return true if @build.canceled?
- if @project.no_running_builds?
- run
- else
- run_later
+ run_in_transaction ? run : run_later
+ end
+
+ def run_in_transaction
+ ActiveRecord::Base.transaction do
+ build.run! if project.no_running_builds?
end
end
@@ -37,8 +39,6 @@ class Runner
commands = commands.lines.to_a
commands.unshift(prepare_project_cmd(path, build.sha))
- build.run!
-
Dir.chdir(path) do
commands.each do |line|
status = command(line, path)
@@ -91,7 +91,7 @@ class Runner
@process.environment['CI_SERVER_REVISION'] = GitlabCi::Revision
@process.environment['CI_BUILD_REF'] = build.ref
-
+
@process.start
build.set_file @tmp_file.path