Skip to content
Snippets Groups Projects
Commit f601ec54 authored by Lin Jen-Shin's avatar Lin Jen-Shin
Browse files

Introduce Projects::ArtifactsController#search:

So we redirect from ref and build_name to the particular build, namely:

* /u/r/artifacts/ref/build_name/* -> /u/r/builds/:build_id/artifacts/*

For:

* download
* browse
* file
parent 8f469c33
No related branches found
No related tags found
1 merge request!5142Add a download buttons for Build Artifacts
Pipeline #
Loading
Loading
@@ -35,14 +35,34 @@ class Projects::ArtifactsController < Projects::ApplicationController
redirect_to namespace_project_build_path(project.namespace, project, build)
end
 
def search
url = namespace_project_build_url(project.namespace, project, build)
if params[:path]
redirect_to "#{url}/artifacts/#{params[:path]}"
else
render_404
end
end
private
 
def validate_artifacts!
render_404 unless build.artifacts?
render_404 unless build && build.artifacts?
end
 
def build
@build ||= project.builds.find_by!(id: params[:build_id])
@build ||= build_from_id || build_from_ref
end
def build_from_id
project.builds.find_by(id: params[:build_id]) if params[:build_id]
end
def build_from_ref
if params[:ref]
project.builds_for(params[:build_name], params[:ref]).latest.first
end
end
 
def artifacts_file
Loading
Loading
Loading
Loading
@@ -733,6 +733,12 @@ Rails.application.routes.draw do
 
resources :environments, only: [:index, :show, :new, :create, :destroy]
 
resources :artifacts, only: [] do
collection do
get :search, path: ':ref/:build_name(/*path)', format: false
end
end
resources :builds, only: [:index, :show], constraints: { id: /\d+/ } do
collection do
post :cancel_all
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment