summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/controllers/projects/artifacts_controller.rb24
-rw-r--r--config/routes.rb6
2 files changed, 28 insertions, 2 deletions
diff --git a/app/controllers/projects/artifacts_controller.rb b/app/controllers/projects/artifacts_controller.rb
index f11c8321464..c00295cd3b5 100644
--- a/app/controllers/projects/artifacts_controller.rb
+++ b/app/controllers/projects/artifacts_controller.rb
@@ -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
diff --git a/config/routes.rb b/config/routes.rb
index 1572656b8c5..0a4b8609252 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -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