Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
heptapod
heptapod
Commits
7bbd98d25ab7
Commit
ef3eb2d9
authored
Oct 20, 2017
by
Nick Thomas
Committed by
Winnie Hellmann
Oct 21, 2017
Browse files
Fix the external URLs generated for online view of HTML artifacts
parent
242487277e20
Changes
3
Show whitespace changes
Inline
Side-by-side
app/models/ci/artifact_blob.rb
View file @
7bbd98d2
...
...
@@ -2,7 +2,7 @@ module Ci
class
ArtifactBlob
include
BlobLike
EXTEN
T
IONS_SERVED_BY_PAGES
=
%w[.html .htm .txt .json]
.
freeze
EXTEN
S
IONS_SERVED_BY_PAGES
=
%w[.html .htm .txt .json]
.
freeze
attr_reader
:entry
...
...
@@ -36,17 +36,22 @@ def external_storage
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
&&
EXTEN
T
IONS_SERVED_BY_PAGES
.
include?
(
File
.
extname
(
name
))
&&
EXTEN
S
IONS_SERVED_BY_PAGES
.
include?
(
File
.
extname
(
name
))
&&
job
.
project
.
public?
end
...
...
changelogs/unreleased/39189-online-view-of-html-artifacts-is-broken.yml
0 → 100644
View file @
7bbd98d2
---
title
:
Fix the external URLs generated for online view of HTML artifacts
merge_request
:
14977
author
:
type
:
fixed
spec/models/ci/artifact_blob_spec.rb
View file @
7bbd98d2
...
...
@@ -56,15 +56,14 @@
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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment