summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzegorz@gitlab.com>2017-10-21 18:26:31 +0000
committerGrzegorz Bizon <grzegorz@gitlab.com>2017-10-21 18:26:31 +0000
commitcfd97f7ebedec56ccf979e21997dfa19e0807205 (patch)
tree642f477bd20834487f4546faa2da5b0ced4ff4e9
parent815a32e29172807cd414dc89a6709f401a4af1ac (diff)
parent3c0be3cd41a72925678df457b040a559a4ba01ee (diff)
downloadgitlab-ce-27375-dashboardcontroller-activity-json-is-slow-due-to-sql.tar.gz
Merge branch '39189-online-view-of-html-artifacts-is-broken' into 'master'27375-dashboardcontroller-activity-json-is-slow-due-to-sql
Resolve "Online view of HTML artifacts is broken?" Closes #39189 See merge request gitlab-org/gitlab-ce!14977
-rw-r--r--app/models/ci/artifact_blob.rb17
-rw-r--r--changelogs/unreleased/39189-online-view-of-html-artifacts-is-broken.yml5
-rw-r--r--spec/models/ci/artifact_blob_spec.rb7
3 files changed, 19 insertions, 10 deletions
diff --git a/app/models/ci/artifact_blob.rb b/app/models/ci/artifact_blob.rb
index 8b66531ec7b..ec56cc53aea 100644
--- a/app/models/ci/artifact_blob.rb
+++ b/app/models/ci/artifact_blob.rb
@@ -2,7 +2,7 @@ module Ci
class ArtifactBlob
include BlobLike
- EXTENTIONS_SERVED_BY_PAGES = %w[.html .htm .txt .json].freeze
+ EXTENSIONS_SERVED_BY_PAGES = %w[.html .htm .txt .json].freeze
attr_reader :entry
@@ -36,17 +36,22 @@ module Ci
def external_url(project, job)
return unless external_link?(job)
- components = project.full_path_components
- components << "-/jobs/#{job.id}/artifacts/file/#{path}"
- artifact_path = components[1..-1].join('/')
+ full_path_parts = project.full_path_components
+ top_level_group = full_path_parts.shift
- "#{pages_config.protocol}://#{components[0]}.#{pages_config.host}/#{artifact_path}"
+ artifact_path = [
+ '-', *full_path_parts, '-',
+ 'jobs', job.id,
+ 'artifacts', path
+ ].join('/')
+
+ "#{pages_config.protocol}://#{top_level_group}.#{pages_config.host}/#{artifact_path}"
end
def external_link?(job)
pages_config.enabled &&
pages_config.artifacts_server &&
- EXTENTIONS_SERVED_BY_PAGES.include?(File.extname(name)) &&
+ EXTENSIONS_SERVED_BY_PAGES.include?(File.extname(name)) &&
job.project.public?
end
diff --git a/changelogs/unreleased/39189-online-view-of-html-artifacts-is-broken.yml b/changelogs/unreleased/39189-online-view-of-html-artifacts-is-broken.yml
new file mode 100644
index 00000000000..3e6ec40a28c
--- /dev/null
+++ b/changelogs/unreleased/39189-online-view-of-html-artifacts-is-broken.yml
@@ -0,0 +1,5 @@
+---
+title: Fix the external URLs generated for online view of HTML artifacts
+merge_request: 14977
+author:
+type: fixed
diff --git a/spec/models/ci/artifact_blob_spec.rb b/spec/models/ci/artifact_blob_spec.rb
index d5ba088af53..4e72d9d748e 100644
--- a/spec/models/ci/artifact_blob_spec.rb
+++ b/spec/models/ci/artifact_blob_spec.rb
@@ -56,15 +56,14 @@ describe Ci::ArtifactBlob do
end
context 'txt extensions' do
- let(:entry) { build.artifacts_metadata_entry('other_artifacts_0.1.2/doc_sample.txt') }
+ let(:path) { 'other_artifacts_0.1.2/doc_sample.txt' }
+ let(:entry) { build.artifacts_metadata_entry(path) }
it 'returns a URL' do
url = subject.external_url(build.project, build)
expect(url).not_to be_nil
- expect(url).to start_with("http")
- expect(url).to match Gitlab.config.pages.host
- expect(url).to end_with(entry.path)
+ expect(url).to eq("http://#{project.namespace.path}.#{Gitlab.config.pages.host}/-/#{project.path}/-/jobs/#{build.id}/artifacts/#{path}")
end
end
end