Commit 8bd230ee authored by Stan Hu's avatar Stan Hu

Merge branch 'fix-no-artifacts-when-exposed' into 'master'

Fix bug when exposing non existing artifacts

See merge request gitlab-org/gitlab!22378
parents f42ac3ee 9492fd9c
......@@ -46,6 +46,8 @@ module Ci
# it could contain many. We only need to know whether it has 1 or more
# artifacts, so fetching the first 2 would be sufficient.
def first_2_metadata_entries_for_artifacts_paths(job)
return [] unless job.artifacts_metadata
job.artifacts_paths
.lazy
.map { |path| job.artifacts_metadata_entry(path, recursive: true) }
......
---
title: Fix bug when trying to expose artifacts and no artifacts are produced by the job
merge_request: 22378
author:
type: fixed
......@@ -50,10 +50,39 @@ describe Ci::FindExposedArtifactsService do
end
end
shared_examples 'does not find any matches' do
it 'returns empty array' do
expect(subject).to eq []
end
end
let_it_be(:pipeline) { create(:ci_pipeline, project: project) }
subject { described_class.new(project, user).for_pipeline(pipeline) }
context 'with jobs having no exposed artifacts' do
let!(:job) do
create_job_with_artifacts(artifacts: {
paths: ['other_artifacts_0.1.2/doc_sample.txt', 'something-else.html']
})
end
it_behaves_like 'does not find any matches'
end
context 'with jobs having no artifacts (metadata)' do
let!(:job) do
create(:ci_build, pipeline: pipeline, options: {
artifacts: {
expose_as: 'Exposed artifact',
paths: ['other_artifacts_0.1.2/doc_sample.txt', 'something-else.html']
}
})
end
it_behaves_like 'does not find any matches'
end
context 'with jobs having at most 1 matching exposed artifact' do
let!(:job) do
create_job_with_artifacts(artifacts: {
......
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