Commit ca3fafb9 authored by Rémy Coutable's avatar Rémy Coutable

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
parents 3d4875f8 fa337ca0
...@@ -103,6 +103,7 @@ v 8.7.0 (unreleased) ...@@ -103,6 +103,7 @@ v 8.7.0 (unreleased)
- Execute system web hooks on push to the project - Execute system web hooks on push to the project
- Allow enable/disable push events for system hooks - Allow enable/disable push events for system hooks
- Fix GitHub project's link in the import page when provider has a custom URL - 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) v 8.6.7 (unreleased)
- Fix persistent XSS vulnerability in `commit_person_link` helper - Fix persistent XSS vulnerability in `commit_person_link` helper
......
class Projects::BuildsController < Projects::ApplicationController class Projects::BuildsController < Projects::ApplicationController
before_action :build, except: [:index, :cancel_all] before_action :build, except: [:index, :cancel_all]
before_action :authorize_read_build!, except: [:cancel, :cancel_all, :retry] 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' layout 'project'
def index def index
...@@ -62,6 +62,14 @@ class Projects::BuildsController < Projects::ApplicationController ...@@ -62,6 +62,14 @@ class Projects::BuildsController < Projects::ApplicationController
notice: "Build has been sucessfully erased!" notice: "Build has been sucessfully erased!"
end 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 private
def build def build
......
...@@ -110,7 +110,7 @@ ...@@ -110,7 +110,7 @@
= icon('folder-open') = icon('folder-open')
Browse Browse
.build-widget .build-widget.build-controls
%h4.title %h4.title
Build ##{@build.id} Build ##{@build.id}
- if can?(current_user, :update_build, @project) - if can?(current_user, :update_build, @project)
...@@ -127,6 +127,9 @@ ...@@ -127,6 +127,9 @@
data: { confirm: 'Are you sure you want to erase this build?' } do data: { confirm: 'Are you sure you want to erase this build?' } do
= icon('eraser') = icon('eraser')
Erase 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 .clearfix
- if @build.duration - if @build.duration
......
...@@ -669,6 +669,7 @@ Rails.application.routes.draw do ...@@ -669,6 +669,7 @@ Rails.application.routes.draw do
post :cancel post :cancel
post :retry post :retry
post :erase post :erase
get :raw
end end
resource :artifacts, only: [] do resource :artifacts, only: [] do
......
...@@ -86,6 +86,20 @@ describe "Builds" do ...@@ -86,6 +86,20 @@ describe "Builds" do
end end
end 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 end
describe "POST /:project/builds/:id/cancel" do describe "POST /:project/builds/:id/cancel" do
...@@ -120,4 +134,20 @@ describe "Builds" do ...@@ -120,4 +134,20 @@ describe "Builds" do
it { expect(page.response_headers['Content-Type']).to eq(artifacts_file.content_type) } it { expect(page.response_headers['Content-Type']).to eq(artifacts_file.content_type) }
end 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 end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment