mirror of
https://github.com/wahyd4/gitlabhq.git
synced 2026-08-11 21:56:19 +10:00
This solves https://dev.gitlab.org/gitlab/gitlabhq/issues/2646 1. This MR simplifies CI permission model: - read_build: allows to read a list of builds, artifacts and trace - update_build: allows to cancel and retry builds - admin_build: allows to manage triggers, runners and variables - read_commit_status: allows to read a list of commit statuses (including the status of a build, but doesn't allow to see a build details) - create_commit_status: allows to create a new commit status using API 2. I do make sure that the proper permissions are used in all places where the CI can be shown. 3. Add the `read_build` ability if user is anonymous or guest and allow_guest_to_access_builds is enabled. 4. Add CI setting: public_builds. 5. The artifacts specific permission are removed, since they are covered by `*_build`.
47 lines
1.0 KiB
Ruby
47 lines
1.0 KiB
Ruby
class Projects::ArtifactsController < Projects::ApplicationController
|
|
layout 'project'
|
|
before_action :authorize_read_build!
|
|
|
|
def download
|
|
unless artifacts_file.file_storage?
|
|
return redirect_to artifacts_file.url
|
|
end
|
|
|
|
unless artifacts_file.exists?
|
|
return render_404
|
|
end
|
|
|
|
send_file artifacts_file.path, disposition: 'attachment'
|
|
end
|
|
|
|
def browse
|
|
return render_404 unless build.artifacts?
|
|
|
|
directory = params[:path] ? "#{params[:path]}/" : ''
|
|
@entry = build.artifacts_metadata_entry(directory)
|
|
|
|
return render_404 unless @entry.exists?
|
|
end
|
|
|
|
def file
|
|
entry = build.artifacts_metadata_entry(params[:path])
|
|
|
|
if entry.exists?
|
|
render json: { archive: build.artifacts_file.path,
|
|
entry: Base64.encode64(entry.path) }
|
|
else
|
|
render json: {}, status: 404
|
|
end
|
|
end
|
|
|
|
private
|
|
|
|
def build
|
|
@build ||= project.builds.unscoped.find_by!(id: params[:build_id])
|
|
end
|
|
|
|
def artifacts_file
|
|
@artifacts_file ||= build.artifacts_file
|
|
end
|
|
end
|