diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2012-12-12 17:59:15 +0200 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2012-12-12 17:59:15 +0200 |
commit | 4ef8a0142f8196336429879d0993f033ac8d0ce3 (patch) | |
tree | 8fea297a3996f7998c1861ad31f609b641a8417c | |
parent | 9c4dc65a50fc202c3e8879e5ae6c8710de2917d3 (diff) | |
download | gitlab-ci-4ef8a0142f8196336429879d0993f033ac8d0ce3.tar.gz |
include git output to logs. make checkout of commit if
-rw-r--r-- | app/controllers/projects_controller.rb | 2 | ||||
-rw-r--r-- | lib/runner.rb | 14 |
2 files changed, 7 insertions, 9 deletions
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 380db5f..d76b692 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -55,7 +55,7 @@ class ProjectsController < ApplicationController @project = Project.find(params[:id]) @build = @project.register_build(ref: params[:ref]) - if @build + if @build and @build.id Resque.enqueue(Runner, @build.id) redirect_to project_build_path(@project, @build) else diff --git a/lib/runner.rb b/lib/runner.rb index 00f1423..b546250 100644 --- a/lib/runner.rb +++ b/lib/runner.rb @@ -23,15 +23,13 @@ class Runner def run path = project.path commands = project.scripts - - return if build.canceled? + commands = commands.lines.to_a + commands.unshift(prepare_project_cmd(path, build.sha)) build.run! - prepare_project(path, build.ref) - Dir.chdir(path) do - commands.each_line do |line| + commands.each do |line| status = command(line, path) build.write_trace(@output) @@ -92,12 +90,12 @@ class Runner @output << @tmp_file.read end - def prepare_project(path, ref) + def prepare_project_cmd(path, ref) cmd = [] cmd << "cd #{path}" cmd << "git fetch" cmd << "git reset --hard" - cmd << "git checkout origin/#{ref}" - `#{cmd.join("&&")}` + cmd << "git checkout #{ref}" + cmd.join(" && ") end end |