Commit e993b8c7 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch 'fix-project-job-path-exposed-artifacts' into 'master'

Use CI source project for path to exposed job artifacts

Closes #37341

See merge request gitlab-org/gitlab!25868
parents 34fc2e47 c07d2365
......@@ -35,7 +35,7 @@ module Ci
{
text: job.artifacts_expose_as,
url: path_for_entries(metadata_entries, job),
job_path: project_job_path(project, job),
job_path: project_job_path(job.project, job),
job_name: job.name
}
end
......@@ -59,9 +59,9 @@ module Ci
return if entries.empty?
if single_artifact?(entries)
file_project_job_artifacts_path(project, job, entries.first.path)
file_project_job_artifacts_path(job.project, job, entries.first.path)
else
browse_project_job_artifacts_path(project, job)
browse_project_job_artifacts_path(job.project, job)
end
end
......
---
title: Fix links to exposed artifacts in MRs from forks
merge_request: 25868
author: Daniel Stone
type: fixed
......@@ -172,5 +172,47 @@ describe Ci::FindExposedArtifactsService do
])
end
end
context 'cross-project MR' do
let!(:foreign_project) { create(:project) }
let!(:pipeline) { create(:ci_pipeline, project: foreign_project) }
let!(:job_show) do
create_job_with_artifacts({
artifacts: {
expose_as: 'file artifact',
paths: ['ci_artifacts.txt']
}
})
end
let!(:job_browse) do
create_job_with_artifacts({
artifacts: {
expose_as: 'directory artifact',
paths: ['tests_encoding/']
}
})
end
subject { described_class.new(project, user).for_pipeline(pipeline, limit: 2) }
it 'returns the correct path for cross-project MRs' do
expect(subject).to eq([
{
text: 'file artifact',
url: file_project_job_artifacts_path(foreign_project, job_show, 'ci_artifacts.txt'),
job_name: job_show.name,
job_path: project_job_path(foreign_project, job_show)
},
{
text: 'directory artifact',
url: browse_project_job_artifacts_path(foreign_project, job_browse),
job_name: job_browse.name,
job_path: project_job_path(foreign_project, job_browse)
}
])
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