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
Léo-Paul Géneau
gitlab-ce
Commits
e09f99b2
Commit
e09f99b2
authored
Mar 29, 2018
by
Alessio Caiazza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add port number to artifacts links to gitlab-pages, if needed
parent
22501582
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
58 additions
and
14 deletions
+58
-14
app/models/ci/artifact_blob.rb
app/models/ci/artifact_blob.rb
+3
-4
app/models/project.rb
app/models/project.rb
+9
-10
changelogs/unreleased/ac-pages-port.yml
changelogs/unreleased/ac-pages-port.yml
+5
-0
spec/models/ci/artifact_blob_spec.rb
spec/models/ci/artifact_blob_spec.rb
+13
-0
spec/models/project_spec.rb
spec/models/project_spec.rb
+28
-0
No files found.
app/models/ci/artifact_blob.rb
View file @
e09f99b2
...
@@ -36,16 +36,15 @@ module Ci
...
@@ -36,16 +36,15 @@ module Ci
def
external_url
(
project
,
job
)
def
external_url
(
project
,
job
)
return
unless
external_link?
(
job
)
return
unless
external_link?
(
job
)
full_path_parts
=
project
.
full_path_components
url_project_path
=
project
.
full_path
.
partition
(
'/'
).
last
top_level_group
=
full_path_parts
.
shift
artifact_path
=
[
artifact_path
=
[
'-'
,
*
full_path_parts
,
'-'
,
'-'
,
url_project_path
,
'-'
,
'jobs'
,
job
.
id
,
'jobs'
,
job
.
id
,
'artifacts'
,
path
'artifacts'
,
path
].
join
(
'/'
)
].
join
(
'/'
)
"
#{
p
ages_config
.
protocol
}
://
#{
top_level_group
}
.
#{
pages_config
.
host
}
/
#{
artifact_path
}
"
"
#{
p
roject
.
pages_group_url
}
/
#{
artifact_path
}
"
end
end
def
external_link?
(
job
)
def
external_link?
(
job
)
...
...
app/models/project.rb
View file @
e09f99b2
...
@@ -1346,20 +1346,19 @@ class Project < ActiveRecord::Base
...
@@ -1346,20 +1346,19 @@ class Project < ActiveRecord::Base
Dir
.
exist?
(
public_pages_path
)
Dir
.
exist?
(
public_pages_path
)
end
end
def
pages_url
def
pages_group_url
subdomain
,
_
,
url_path
=
full_path
.
partition
(
'/'
)
# The hostname always needs to be in downcased
# All web servers convert hostname to lowercase
host
=
"
#{
subdomain
}
.
#{
Settings
.
pages
.
host
}
"
.
downcase
# The host in URL always needs to be downcased
# The host in URL always needs to be downcased
url
=
Gitlab
.
config
.
pages
.
url
.
sub
(
%r{^https?://}
)
do
|
prefix
|
Gitlab
.
config
.
pages
.
url
.
sub
(
%r{^https?://}
)
do
|
prefix
|
"
#{
prefix
}#{
subdomain
}
."
"
#{
prefix
}#{
pages_
subdomain
}
."
end
.
downcase
end
.
downcase
end
def
pages_url
url
=
pages_group_url
url_path
=
full_path
.
partition
(
'/'
).
last
# If the project path is the same as host, we serve it as group page
# If the project path is the same as host, we serve it as group page
return
url
if
host
==
url_path
return
url
if
url
==
"
#{
Settings
.
pages
.
protocol
}
://
#{
url_path
}
"
"
#{
url
}
/
#{
url_path
}
"
"
#{
url
}
/
#{
url_path
}
"
end
end
...
...
changelogs/unreleased/ac-pages-port.yml
0 → 100644
View file @
e09f99b2
---
title
:
Add missing port to artifact links
merge_request
:
author
:
type
:
fixed
spec/models/ci/artifact_blob_spec.rb
View file @
e09f99b2
...
@@ -65,6 +65,19 @@ describe Ci::ArtifactBlob do
...
@@ -65,6 +65,19 @@ describe Ci::ArtifactBlob do
expect
(
url
).
not_to
be_nil
expect
(
url
).
not_to
be_nil
expect
(
url
).
to
eq
(
"http://
#{
project
.
namespace
.
path
}
.
#{
Gitlab
.
config
.
pages
.
host
}
/-/
#{
project
.
path
}
/-/jobs/
#{
build
.
id
}
/artifacts/
#{
path
}
"
)
expect
(
url
).
to
eq
(
"http://
#{
project
.
namespace
.
path
}
.
#{
Gitlab
.
config
.
pages
.
host
}
/-/
#{
project
.
path
}
/-/jobs/
#{
build
.
id
}
/artifacts/
#{
path
}
"
)
end
end
context
'when port is configured'
do
let
(
:port
)
{
1234
}
it
'returns an URL with port number'
do
allow
(
Gitlab
.
config
.
pages
).
to
receive
(
:url
).
and_return
(
"
#{
Gitlab
.
config
.
pages
.
url
}
:
#{
port
}
"
)
url
=
subject
.
external_url
(
build
.
project
,
build
)
expect
(
url
).
not_to
be_nil
expect
(
url
).
to
eq
(
"http://
#{
project
.
namespace
.
path
}
.
#{
Gitlab
.
config
.
pages
.
host
}
:
#{
port
}
/-/
#{
project
.
path
}
/-/jobs/
#{
build
.
id
}
/artifacts/
#{
path
}
"
)
end
end
end
end
end
end
...
...
spec/models/project_spec.rb
View file @
e09f99b2
...
@@ -1265,6 +1265,34 @@ describe Project do
...
@@ -1265,6 +1265,34 @@ describe Project do
end
end
end
end
describe
'#pages_group_url'
do
let
(
:group
)
{
create
:group
,
name:
group_name
}
let
(
:project
)
{
create
:project
,
namespace:
group
,
name:
project_name
}
let
(
:domain
)
{
'Example.com'
}
let
(
:port
)
{
1234
}
subject
{
project
.
pages_group_url
}
before
do
allow
(
Settings
.
pages
).
to
receive
(
:host
).
and_return
(
domain
)
allow
(
Gitlab
.
config
.
pages
).
to
receive
(
:url
).
and_return
(
"http://example.com:
#{
port
}
"
)
end
context
'group page'
do
let
(
:group_name
)
{
'Group'
}
let
(
:project_name
)
{
'group.example.com'
}
it
{
is_expected
.
to
eq
(
"http://group.example.com:
#{
port
}
"
)
}
end
context
'project page'
do
let
(
:group_name
)
{
'Group'
}
let
(
:project_name
)
{
'Project'
}
it
{
is_expected
.
to
eq
(
"http://group.example.com:
#{
port
}
"
)
}
end
end
describe
'.search'
do
describe
'.search'
do
let
(
:project
)
{
create
(
:project
,
description:
'kitten mittens'
)
}
let
(
:project
)
{
create
(
:project
,
description:
'kitten mittens'
)
}
...
...
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