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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
6c6c7c3c
Commit
6c6c7c3c
authored
Sep 28, 2015
by
Chris Rohr
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Addresses regression with jenkins setup that does not use the multiproject setup
parent
54878022
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
16 deletions
+60
-16
app/models/project_services/jenkins_service.rb
app/models/project_services/jenkins_service.rb
+14
-3
spec/models/project_services/jenkins_service_spec.rb
spec/models/project_services/jenkins_service_spec.rb
+46
-13
No files found.
app/models/project_services/jenkins_service.rb
View file @
6c6c7c3c
...
...
@@ -14,6 +14,7 @@
class
JenkinsService
<
CiService
prop_accessor
:project_url
prop_accessor
:multiproject_enabled
validates
:project_url
,
presence:
true
,
if: :activated?
...
...
@@ -46,13 +47,23 @@ class JenkinsService < CiService
def
fields
[
{
type:
'text'
,
name:
'project_url'
,
placeholder:
'Jenkins project URL like http://jenkins.example.com/job/my-project/'
}
{
type:
'text'
,
name:
'project_url'
,
placeholder:
'Jenkins project URL like http://jenkins.example.com/job/my-project/'
},
{
type:
'checkbox'
,
name:
'multiproject_enabled'
,
title:
"Multi-project setup enabled?"
,
help:
"Multi-project mode is configured in Jenkins Gitlab Hook plugin."
}
]
end
def
multiproject_enabled?
self
.
multiproject_enabled
==
'1'
end
def
build_page
(
sha
,
ref
=
nil
)
base_url
=
ref
.
nil?
||
ref
==
'master'
?
project_url
:
"
#{
project_url
}
_
#{
ref
}
"
base_url
+
"/scm/bySHA1/
#{
sha
}
"
if
multiproject_enabled?
base_url
=
ref
.
nil?
||
ref
==
'master'
?
project_url
:
"
#{
project_url
}
_
#{
ref
}
"
base_url
+
"/scm/bySHA1/
#{
sha
}
"
else
project_url
+
"/scm/bySHA1/
#{
sha
}
"
end
end
def
commit_status
(
sha
,
ref
=
nil
)
...
...
spec/models/project_services/jenkins_service_spec.rb
View file @
6c6c7c3c
...
...
@@ -35,16 +35,17 @@ describe JenkinsService do
eos
end
before
do
@service
=
JenkinsService
.
new
allow
(
@service
).
to
receive_messages
(
service_hook:
true
,
project_url:
'http://jenkins.gitlab.org/projects/2'
,
token:
'verySecret'
)
end
describe
:commit_status
do
before
do
@service
=
JenkinsService
.
new
allow
(
@service
).
to
receive_messages
(
service_hook:
true
,
project_url:
'http://jenkins.gitlab.org/projects/2'
,
multiproject_enabled:
'1'
,
token:
'verySecret'
)
end
statuses
=
{
'blue.png'
=>
'success'
,
'yellow.png'
=>
'failed'
,
'red.png'
=>
'failed'
,
'aborted.png'
=>
'failed'
,
'blue-anime.gif'
=>
'running'
,
'grey.png'
=>
'pending'
}
statuses
.
each
do
|
icon
,
state
|
it
"should have a status of
#{
state
}
when the icon
#{
icon
}
exists."
do
...
...
@@ -54,12 +55,44 @@ eos
end
end
describe
:build_page
do
it
{
expect
(
@service
.
build_page
(
"2ab7834c"
,
'master'
)).
to
eq
(
"http://jenkins.gitlab.org/projects/2/scm/bySHA1/2ab7834c"
)
}
describe
'multiproject enabled'
do
before
do
@service
=
JenkinsService
.
new
allow
(
@service
).
to
receive_messages
(
service_hook:
true
,
project_url:
'http://jenkins.gitlab.org/projects/2'
,
multiproject_enabled:
'1'
,
token:
'verySecret'
)
end
describe
:build_page
do
it
{
expect
(
@service
.
build_page
(
"2ab7834c"
,
'master'
)).
to
eq
(
"http://jenkins.gitlab.org/projects/2/scm/bySHA1/2ab7834c"
)
}
end
describe
:build_page_with_branch
do
it
{
expect
(
@service
.
build_page
(
"2ab7834c"
,
'test_branch'
)).
to
eq
(
"http://jenkins.gitlab.org/projects/2_test_branch/scm/bySHA1/2ab7834c"
)
}
end
end
describe
:build_page_with_branch
do
it
{
expect
(
@service
.
build_page
(
"2ab7834c"
,
'test_branch'
)).
to
eq
(
"http://jenkins.gitlab.org/projects/2_test_branch/scm/bySHA1/2ab7834c"
)
}
describe
'multiproject disabled'
do
before
do
@service
=
JenkinsService
.
new
allow
(
@service
).
to
receive_messages
(
service_hook:
true
,
project_url:
'http://jenkins.gitlab.org/projects/2'
,
multiproject_enabled:
'0'
,
token:
'verySecret'
)
end
describe
:build_page
do
it
{
expect
(
@service
.
build_page
(
"2ab7834c"
,
'master'
)).
to
eq
(
"http://jenkins.gitlab.org/projects/2/scm/bySHA1/2ab7834c"
)
}
end
describe
:build_page_with_branch
do
it
{
expect
(
@service
.
build_page
(
"2ab7834c"
,
'test_branch'
)).
to
eq
(
"http://jenkins.gitlab.org/projects/2/scm/bySHA1/2ab7834c"
)
}
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