Commit 1646149f authored by GitLab Bot's avatar GitLab Bot

Add latest changes from gitlab-org/gitlab@12-10-stable-ee

parent 4467fbd0
...@@ -111,7 +111,7 @@ class Projects::ArtifactsController < Projects::ApplicationController ...@@ -111,7 +111,7 @@ class Projects::ArtifactsController < Projects::ApplicationController
def build def build
@build ||= begin @build ||= begin
build = build_from_id || build_from_ref build = build_from_id || build_from_sha || build_from_ref
build&.present(current_user: current_user) build&.present(current_user: current_user)
end end
end end
...@@ -125,7 +125,8 @@ class Projects::ArtifactsController < Projects::ApplicationController ...@@ -125,7 +125,8 @@ class Projects::ArtifactsController < Projects::ApplicationController
project.builds.find_by_id(params[:job_id]) if params[:job_id] project.builds.find_by_id(params[:job_id]) if params[:job_id]
end end
def build_from_ref def build_from_sha
return if params[:job].blank?
return unless @ref_name return unless @ref_name
commit = project.commit(@ref_name) commit = project.commit(@ref_name)
...@@ -134,6 +135,13 @@ class Projects::ArtifactsController < Projects::ApplicationController ...@@ -134,6 +135,13 @@ class Projects::ArtifactsController < Projects::ApplicationController
project.latest_successful_build_for_sha(params[:job], commit.id) project.latest_successful_build_for_sha(params[:job], commit.id)
end end
def build_from_ref
return if params[:job].blank?
return unless @ref_name
project.latest_successful_build_for_ref(params[:job], @ref_name)
end
def artifacts_file def artifacts_file
@artifacts_file ||= build&.artifacts_file_for_type(params[:file_type] || :archive) @artifacts_file ||= build&.artifacts_file_for_type(params[:file_type] || :archive)
end end
......
---
title: Fix Geo replication for design thumbnails
merge_request: 32703
author:
type: fixed
---
title: Fix 404s downloading build artifacts
merge_request: 32741
author:
type: fixed
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
require 'spec_helper' require 'spec_helper'
describe Projects::ArtifactsController do describe Projects::ArtifactsController do
include RepoHelpers
let(:user) { project.owner } let(:user) { project.owner }
let_it_be(:project) { create(:project, :repository, :public) } let_it_be(:project) { create(:project, :repository, :public) }
...@@ -447,6 +449,22 @@ describe Projects::ArtifactsController do ...@@ -447,6 +449,22 @@ describe Projects::ArtifactsController do
expect(response).to redirect_to(path) expect(response).to redirect_to(path)
end end
end end
context 'with a failed pipeline on an updated master' do
before do
create_file_in_repo(project, 'master', 'master', 'test.txt', 'This is test')
create(:ci_pipeline,
project: project,
sha: project.commit.sha,
ref: project.default_branch,
status: 'failed')
get :latest_succeeded, params: params_from_ref(project.default_branch)
end
it_behaves_like 'redirect to the job'
end
end end
end end
end end
...@@ -32,5 +32,11 @@ describe "User downloads artifacts" do ...@@ -32,5 +32,11 @@ describe "User downloads artifacts" do
it_behaves_like "downloading" it_behaves_like "downloading"
end end
context "via SHA" do
let(:url) { latest_succeeded_project_artifacts_path(project, "#{pipeline.sha}/download", job: job.name) }
it_behaves_like "downloading"
end
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