diff options
author | Rémy Coutable <remy@rymai.me> | 2016-04-20 08:11:50 +0000 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2016-04-20 10:49:56 +0200 |
commit | aa49124ef42fae4d5c60d7ca5fb176d55a72a8df (patch) | |
tree | fd0185a024548a95ca1eb57b0838c7c09922c59d | |
parent | b255cbf396f15638acb80aff6c792d9913785cf6 (diff) | |
download | gitlab-ce-aa49124ef42fae4d5c60d7ca5fb176d55a72a8df.tar.gz |
Merge branch 'feature/raw-trace-output' into 'master'
Add raw build trace output
Closes #15308, #15147
Changes in the UI:
- on finished build:
![raw-on-finished-build](/uploads/0e0904940db5b381ae064d49343c6508/raw-on-finished-build.png)
- on running build:
![raw-on-running-build](/uploads/0e4c800b68c12bdd0cbd2eea732b22ff/raw-on-running-build.png)
See merge request !3767
-rw-r--r-- | CHANGELOG | 1 | ||||
-rw-r--r-- | app/controllers/projects/builds_controller.rb | 10 | ||||
-rw-r--r-- | app/views/projects/builds/show.html.haml | 5 | ||||
-rw-r--r-- | config/routes.rb | 1 | ||||
-rw-r--r-- | spec/features/builds_spec.rb | 30 |
5 files changed, 45 insertions, 2 deletions
diff --git a/CHANGELOG b/CHANGELOG index 0eb37667441..b1a52aa5f23 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -99,6 +99,7 @@ v 8.7.0 (unreleased) - Execute system web hooks on push to the project - Allow enable/disable push events for system hooks - Fix GitHub project's link in the import page when provider has a custom URL + - Add RAW build trace output and button on build page v 8.6.7 (unreleased) - Fix vulnerability that made it possible to enumerate private projects belonging to group diff --git a/app/controllers/projects/builds_controller.rb b/app/controllers/projects/builds_controller.rb index f159e169f6d..b8b9e78427d 100644 --- a/app/controllers/projects/builds_controller.rb +++ b/app/controllers/projects/builds_controller.rb @@ -1,7 +1,7 @@ class Projects::BuildsController < Projects::ApplicationController before_action :build, except: [:index, :cancel_all] before_action :authorize_read_build!, except: [:cancel, :cancel_all, :retry] - before_action :authorize_update_build!, except: [:index, :show, :status] + before_action :authorize_update_build!, except: [:index, :show, :status, :raw] layout 'project' def index @@ -62,6 +62,14 @@ class Projects::BuildsController < Projects::ApplicationController notice: "Build has been sucessfully erased!" end + def raw + if @build.has_trace? + send_file @build.path_to_trace, type: 'text/plain; charset=utf-8', disposition: 'inline' + else + render_404 + end + end + private def build diff --git a/app/views/projects/builds/show.html.haml b/app/views/projects/builds/show.html.haml index aa8827b5ac8..6d4505ebb60 100644 --- a/app/views/projects/builds/show.html.haml +++ b/app/views/projects/builds/show.html.haml @@ -110,7 +110,7 @@ = icon('folder-open') Browse - .build-widget + .build-widget.build-controls %h4.title Build ##{@build.id} - if can?(current_user, :update_build, @project) @@ -127,6 +127,9 @@ data: { confirm: 'Are you sure you want to erase this build?' } do = icon('eraser') Erase + - if @build.has_trace? + = link_to 'Raw', raw_namespace_project_build_path(@project.namespace, @project, @build), + class: 'btn btn-sm btn-success', target: '_blank' .clearfix - if @build.duration diff --git a/config/routes.rb b/config/routes.rb index b9f30ede524..79b62a0b1bb 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -669,6 +669,7 @@ Rails.application.routes.draw do post :cancel post :retry post :erase + get :raw end resource :artifacts, only: [] do diff --git a/spec/features/builds_spec.rb b/spec/features/builds_spec.rb index 6da3a857b3f..090a941958f 100644 --- a/spec/features/builds_spec.rb +++ b/spec/features/builds_spec.rb @@ -86,6 +86,20 @@ describe "Builds" do end end end + + context 'Build raw trace' do + before do + @build.run! + @build.trace = 'BUILD TRACE' + visit namespace_project_build_path(@project.namespace, @project, @build) + end + + it do + page.within('.build-controls') do + expect(page).to have_link 'Raw' + end + end + end end describe "POST /:project/builds/:id/cancel" do @@ -120,4 +134,20 @@ describe "Builds" do it { expect(page.response_headers['Content-Type']).to eq(artifacts_file.content_type) } end + + describe "GET /:project/builds/:id/raw" do + before do + Capybara.current_session.driver.header('X-Sendfile-Type', 'X-Sendfile') + @build.run! + @build.trace = 'BUILD TRACE' + visit namespace_project_build_path(@project.namespace, @project, @build) + end + + it 'sends the right headers' do + page.within('.build-controls') { click_link 'Raw' } + + expect(page.response_headers['Content-Type']).to eq('text/plain; charset=utf-8') + expect(page.response_headers['X-Sendfile']).to eq(@build.path_to_trace) + end + end end |