Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
gitlab-ce
Commits
ca0e3904
Commit
ca0e3904
authored
Sep 21, 2017
by
Zeger-Jan van de Weg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Backend for HTML serving with GitLab Pages
parent
3265ccfc
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
87 additions
and
4 deletions
+87
-4
app/helpers/artifact_helper.rb
app/helpers/artifact_helper.rb
+31
-0
app/views/projects/artifacts/_tree_file.html.haml
app/views/projects/artifacts/_tree_file.html.haml
+3
-4
config/gitlab.yml.example
config/gitlab.yml.example
+1
-0
spec/fixtures/ci_build_artifacts.zip
spec/fixtures/ci_build_artifacts.zip
+0
-0
spec/helpers/artifact_helper_spec.rb
spec/helpers/artifact_helper_spec.rb
+52
-0
No files found.
app/helpers/artifact_helper.rb
0 → 100644
View file @
ca0e3904
module
ArtifactHelper
include
GitlabRoutingHelper
def
link_to_artifact
(
project
,
job
,
file
)
if
external_url?
(
file
.
blob
)
html_artifact_url
(
project
,
job
,
file
.
blob
)
else
file_project_job_artifacts_path
(
project
,
job
,
path:
file
.
path
)
end
end
def
external_url?
(
blob
)
blob
.
name
.
end_with?
(
".html"
)
&&
pages_config
.
enabled
&&
pages_config
.
artifacts_server
end
private
def
html_artifact_url
(
project
,
job
,
blob
)
http
=
pages_config
.
https
?
"https://"
:
"http://"
domain
=
"
#{
project
.
namespace
.
to_param
}
.
#{
pages_config
.
host
}
/"
path
=
"-/jobs/
#{
job
.
id
}
/artifacts/
#{
blob
.
path
}
"
http
+
domain
+
path
end
def
pages_config
Gitlab
.
config
.
pages
end
end
app/views/projects/artifacts/_tree_file.html.haml
View file @
ca0e3904
-
todo_external_artifacts_path
=
'https://google.com'
-
is_external_link
=
!
todo_external_artifacts_path
.
blank?
-
path_to_file
=
todo_external_artifacts_path
||
file_project_job_artifacts_path
(
@project
,
@build
,
path:
file
.
path
)
-
blob
=
file
.
blob
-
is_external_link
=
external_link?
(
blob
)
-
path_to_file
=
link_to_artifact
(
@project
,
@build
,
file
)
%tr
.tree-item.js-artifact-tree-row
{
data:
{
link:
path_to_file
,
external_link:
"#{is_external_link}"
}
}
-
blob
=
file
.
blob
%td
.tree-item-file-name
=
tree_icon
(
'file'
,
blob
.
mode
,
blob
.
name
)
=
link_to
path_to_file
,
...
...
config/gitlab.yml.example
View file @
ca0e3904
...
...
@@ -164,6 +164,7 @@ production: &base
host: example.com
port: 80 # Set to 443 if you serve the pages with HTTPS
https: false # Set to true if you serve the pages with HTTPS
artifacts_server: true
# external_http: ["1.1.1.1:80", "[2001::1]:80"] # If defined, enables custom domain support in GitLab Pages
# external_https: ["1.1.1.1:443", "[2001::1]:443"] # If defined, enables custom domain and certificate support in GitLab Pages
...
...
spec/fixtures/ci_build_artifacts.zip
View file @
ca0e3904
No preview for this file type
spec/helpers/artifact_helper_spec.rb
0 → 100644
View file @
ca0e3904
require
'spec_helper'
describe
ArtifactHelper
do
set
(
:job
)
{
create
(
:ci_build
,
:artifacts
)
}
let
(
:html_entry
)
{
job
.
artifacts_metadata_entry
(
"other_artifacts_0.1.2/index.html"
)
}
let
(
:txt_entry
)
{
job
.
artifacts_metadata_entry
(
"other_artifacts_0.1.2/doc_sample.txt"
)
}
before
do
allow
(
Gitlab
.
config
.
pages
).
to
receive
(
:enabled
).
and_return
(
true
)
allow
(
Gitlab
.
config
.
pages
).
to
receive
(
:artifacts_server
).
and_return
(
true
)
end
describe
'#link_to_artifact'
do
context
'link_to_pages returns true'
do
subject
{
link_to_artifact
(
job
.
project
,
job
,
entry
)
}
before
do
allow
(
Gitlab
.
config
.
pages
).
to
receive
(
:enabled
).
and_return
(
true
)
end
context
'when the entry is HTML'
do
let
(
:entry
)
{
html_entry
}
it
{
is_expected
.
to
match
Gitlab
.
config
.
pages
.
host
}
it
{
is_expected
.
to
match
/-\/jobs\/\d+\/artifacts/
}
end
context
'when the entry is not HTML'
do
let
(
:entry
)
{
txt_entry
}
it
{
is_expected
.
not_to
match
Gitlab
.
config
.
pages
.
host
}
end
end
end
describe
'#external_url?'
do
context
'pages enabled'
do
before
do
allow
(
Gitlab
.
config
.
pages
).
to
receive
(
:artifacts_server
).
and_return
(
true
)
end
it
'returns true for HTML files'
do
expect
(
external_url?
(
txt_entry
.
blob
)).
to
be
(
false
)
end
it
'returns true for HTML files'
do
expect
(
external_url?
(
html_entry
.
blob
)).
to
be
(
true
)
end
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