2018-09-25 23:45:43 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-05-23 09:20:59 -04:00
|
|
|
class Projects::BuildArtifactsController < Projects::ApplicationController
|
|
|
|
include ExtractsPath
|
|
|
|
include RendersBlob
|
|
|
|
|
2017-05-23 11:42:26 -04:00
|
|
|
before_action :authorize_read_build!
|
2017-05-23 09:20:59 -04:00
|
|
|
before_action :extract_ref_name_and_path
|
2018-10-16 09:01:48 -04:00
|
|
|
before_action :validate_artifacts!, except: [:download]
|
2017-05-23 09:20:59 -04:00
|
|
|
|
2020-10-08 14:08:32 -04:00
|
|
|
feature_category :continuous_integration
|
|
|
|
|
2017-05-23 09:20:59 -04:00
|
|
|
def download
|
2018-10-16 09:01:48 -04:00
|
|
|
redirect_to download_project_job_artifacts_path(project, job, params: request.query_parameters)
|
2017-05-23 09:20:59 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def browse
|
2017-06-29 13:06:35 -04:00
|
|
|
redirect_to browse_project_job_artifacts_path(project, job, path: params[:path])
|
2017-05-23 09:20:59 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def file
|
2017-06-29 13:06:35 -04:00
|
|
|
redirect_to file_project_job_artifacts_path(project, job, path: params[:path])
|
2017-05-23 09:20:59 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def raw
|
2017-06-29 13:06:35 -04:00
|
|
|
redirect_to raw_project_job_artifacts_path(project, job, path: params[:path])
|
2017-05-23 09:20:59 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def latest_succeeded
|
2017-06-29 13:06:35 -04:00
|
|
|
redirect_to latest_succeeded_project_artifacts_path(project, job, ref_name_and_path: params[:ref_name_and_path], job: params[:job])
|
2017-05-23 09:20:59 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2017-05-23 11:42:26 -04:00
|
|
|
def validate_artifacts!
|
|
|
|
render_404 unless job && job.artifacts?
|
|
|
|
end
|
|
|
|
|
2017-05-23 09:20:59 -04:00
|
|
|
def extract_ref_name_and_path
|
|
|
|
return unless params[:ref_name_and_path]
|
|
|
|
|
|
|
|
@ref_name, @path = extract_ref(params[:ref_name_and_path])
|
|
|
|
end
|
|
|
|
|
|
|
|
def job
|
|
|
|
@job ||= job_from_id || job_from_ref
|
|
|
|
end
|
|
|
|
|
|
|
|
def job_from_id
|
2019-01-09 10:33:22 -05:00
|
|
|
project.builds.find_by_id(params[:build_id]) if params[:build_id]
|
2017-05-23 09:20:59 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def job_from_ref
|
|
|
|
return unless @ref_name
|
|
|
|
|
2019-07-23 15:29:12 -04:00
|
|
|
project.latest_successful_build_for_ref(params[:job], @ref_name)
|
2017-05-23 09:20:59 -04:00
|
|
|
end
|
|
|
|
end
|