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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
d57e809c
Commit
d57e809c
authored
Feb 28, 2015
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Set supported events per project service.
parent
85fa334e
Changes
19
Show whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
156 additions
and
57 deletions
+156
-57
app/models/project_services/asana_service.rb
app/models/project_services/asana_service.rb
+5
-2
app/models/project_services/assembla_service.rb
app/models/project_services/assembla_service.rb
+5
-2
app/models/project_services/bamboo_service.rb
app/models/project_services/bamboo_service.rb
+5
-2
app/models/project_services/buildbox_service.rb
app/models/project_services/buildbox_service.rb
+5
-2
app/models/project_services/campfire_service.rb
app/models/project_services/campfire_service.rb
+5
-2
app/models/project_services/ci_service.rb
app/models/project_services/ci_service.rb
+4
-0
app/models/project_services/emails_on_push_service.rb
app/models/project_services/emails_on_push_service.rb
+5
-2
app/models/project_services/flowdock_service.rb
app/models/project_services/flowdock_service.rb
+5
-2
app/models/project_services/gemnasium_service.rb
app/models/project_services/gemnasium_service.rb
+5
-2
app/models/project_services/gitlab_ci_service.rb
app/models/project_services/gitlab_ci_service.rb
+5
-2
app/models/project_services/hipchat_service.rb
app/models/project_services/hipchat_service.rb
+5
-2
app/models/project_services/issue_tracker_service.rb
app/models/project_services/issue_tracker_service.rb
+5
-2
app/models/project_services/pivotaltracker_service.rb
app/models/project_services/pivotaltracker_service.rb
+5
-2
app/models/project_services/pushover_service.rb
app/models/project_services/pushover_service.rb
+5
-2
app/models/project_services/slack_service.rb
app/models/project_services/slack_service.rb
+5
-0
app/models/project_services/teamcity_service.rb
app/models/project_services/teamcity_service.rb
+5
-2
app/models/service.rb
app/models/service.rb
+6
-0
app/views/admin/services/_form.html.haml
app/views/admin/services/_form.html.haml
+37
-0
app/views/projects/services/_form.html.haml
app/views/projects/services/_form.html.haml
+34
-29
No files found.
app/models/project_services/asana_service.rb
View file @
d57e809c
...
@@ -65,9 +65,12 @@ automatically inspected. Leave blank to include all branches.'
...
@@ -65,9 +65,12 @@ automatically inspected. Leave blank to include all branches.'
]
]
end
end
def
supported_events
%w(push)
end
def
execute
(
data
)
def
execute
(
data
)
object_kind
=
data
[
:object_kind
]
return
unless
supported_events
.
include?
(
data
[
:object_kind
])
return
unless
object_kind
==
"push"
Asana
.
configure
do
|
client
|
Asana
.
configure
do
|
client
|
client
.
api_key
=
api_key
client
.
api_key
=
api_key
...
...
app/models/project_services/assembla_service.rb
View file @
d57e809c
...
@@ -42,9 +42,12 @@ class AssemblaService < Service
...
@@ -42,9 +42,12 @@ class AssemblaService < Service
]
]
end
end
def
supported_events
%w(push)
end
def
execute
(
data
)
def
execute
(
data
)
object_kind
=
data
[
:object_kind
]
return
unless
supported_events
.
include?
(
data
[
:object_kind
])
return
unless
object_kind
==
"push"
url
=
"https://atlas.assembla.com/spaces/
#{
subdomain
}
/github_tool?secret_key=
#{
token
}
"
url
=
"https://atlas.assembla.com/spaces/
#{
subdomain
}
/github_tool?secret_key=
#{
token
}
"
AssemblaService
.
post
(
url
,
body:
{
payload:
data
}.
to_json
,
headers:
{
'Content-Type'
=>
'application/json'
})
AssemblaService
.
post
(
url
,
body:
{
payload:
data
}.
to_json
,
headers:
{
'Content-Type'
=>
'application/json'
})
...
...
app/models/project_services/bamboo_service.rb
View file @
d57e809c
...
@@ -73,6 +73,10 @@ class BambooService < CiService
...
@@ -73,6 +73,10 @@ class BambooService < CiService
]
]
end
end
def
supported_events
%w(push)
end
def
build_info
(
sha
)
def
build_info
(
sha
)
url
=
URI
.
parse
(
"
#{
bamboo_url
}
/rest/api/latest/result?label=
#{
sha
}
"
)
url
=
URI
.
parse
(
"
#{
bamboo_url
}
/rest/api/latest/result?label=
#{
sha
}
"
)
...
@@ -123,8 +127,7 @@ class BambooService < CiService
...
@@ -123,8 +127,7 @@ class BambooService < CiService
end
end
def
execute
(
data
)
def
execute
(
data
)
object_kind
=
data
[
:object_kind
]
return
unless
supported_events
.
include?
(
data
[
:object_kind
])
return
unless
object_kind
==
"push"
# Bamboo requires a GET and does not take any data.
# Bamboo requires a GET and does not take any data.
self
.
class
.
get
(
"
#{
bamboo_url
}
/updateAndBuild.action?buildKey=
#{
build_key
}
"
,
self
.
class
.
get
(
"
#{
bamboo_url
}
/updateAndBuild.action?buildKey=
#{
build_key
}
"
,
...
...
app/models/project_services/buildbox_service.rb
View file @
d57e809c
...
@@ -36,9 +36,12 @@ class BuildboxService < CiService
...
@@ -36,9 +36,12 @@ class BuildboxService < CiService
hook
.
save
hook
.
save
end
end
def
supported_events
%w(push)
end
def
execute
(
data
)
def
execute
(
data
)
object_kind
=
data
[
:object_kind
]
return
unless
supported_events
.
include?
(
data
[
:object_kind
])
return
unless
object_kind
==
"push"
service_hook
.
execute
(
data
)
service_hook
.
execute
(
data
)
end
end
...
...
app/models/project_services/campfire_service.rb
View file @
d57e809c
...
@@ -41,9 +41,12 @@ class CampfireService < Service
...
@@ -41,9 +41,12 @@ class CampfireService < Service
]
]
end
end
def
supported_events
%w(push)
end
def
execute
(
data
)
def
execute
(
data
)
object_kind
=
data
[
:object_kind
]
return
unless
supported_events
.
include?
(
data
[
:object_kind
])
return
unless
object_kind
==
"push"
room
=
gate
.
find_room_by_name
(
self
.
room
)
room
=
gate
.
find_room_by_name
(
self
.
room
)
return
true
unless
room
return
true
unless
room
...
...
app/models/project_services/ci_service.rb
View file @
d57e809c
...
@@ -25,6 +25,10 @@ class CiService < Service
...
@@ -25,6 +25,10 @@ class CiService < Service
:ci
:ci
end
end
def
supported_events
%w(push)
end
# Return complete url to build page
# Return complete url to build page
#
#
# Ex.
# Ex.
...
...
app/models/project_services/emails_on_push_service.rb
View file @
d57e809c
...
@@ -33,9 +33,12 @@ class EmailsOnPushService < Service
...
@@ -33,9 +33,12 @@ class EmailsOnPushService < Service
'emails_on_push'
'emails_on_push'
end
end
def
supported_events
%w(push)
end
def
execute
(
data
)
def
execute
(
data
)
object_kind
=
data
[
:object_kind
]
return
unless
supported_events
.
include?
(
data
[
:object_kind
])
return
unless
object_kind
==
"push"
EmailsOnPushWorker
.
perform_async
(
project_id
,
recipients
,
data
)
EmailsOnPushWorker
.
perform_async
(
project_id
,
recipients
,
data
)
end
end
...
...
app/models/project_services/flowdock_service.rb
View file @
d57e809c
...
@@ -41,9 +41,12 @@ class FlowdockService < Service
...
@@ -41,9 +41,12 @@ class FlowdockService < Service
]
]
end
end
def
supported_events
%w(push)
end
def
execute
(
data
)
def
execute
(
data
)
object_kind
=
data
[
:object_kind
]
return
unless
supported_events
.
include?
(
data
[
:object_kind
])
return
unless
object_kind
==
"push"
Flowdock
::
Git
.
post
(
Flowdock
::
Git
.
post
(
data
[
:ref
],
data
[
:ref
],
...
...
app/models/project_services/gemnasium_service.rb
View file @
d57e809c
...
@@ -42,9 +42,12 @@ class GemnasiumService < Service
...
@@ -42,9 +42,12 @@ class GemnasiumService < Service
]
]
end
end
def
supported_events
%w(push)
end
def
execute
(
data
)
def
execute
(
data
)
object_kind
=
data
[
:object_kind
]
return
unless
supported_events
.
include?
(
data
[
:object_kind
])
return
unless
object_kind
==
"push"
Gemnasium
::
GitlabService
.
execute
(
Gemnasium
::
GitlabService
.
execute
(
ref:
data
[
:ref
],
ref:
data
[
:ref
],
...
...
app/models/project_services/gitlab_ci_service.rb
View file @
d57e809c
...
@@ -30,9 +30,12 @@ class GitlabCiService < CiService
...
@@ -30,9 +30,12 @@ class GitlabCiService < CiService
hook
.
save
hook
.
save
end
end
def
supported_events
%w(push tag_push)
end
def
execute
(
data
)
def
execute
(
data
)
object_kind
=
data
[
:object_kind
]
return
unless
supported_events
.
include?
(
data
[
:object_kind
])
return
unless
%w(push tag_push)
.
include?
(
object_kind
)
service_hook
.
execute
(
data
)
service_hook
.
execute
(
data
)
end
end
...
...
app/models/project_services/hipchat_service.rb
View file @
d57e809c
...
@@ -44,9 +44,12 @@ class HipchatService < Service
...
@@ -44,9 +44,12 @@ class HipchatService < Service
]
]
end
end
def
supported_events
%w(push)
end
def
execute
(
data
)
def
execute
(
data
)
object_kind
=
data
[
:object_kind
]
return
unless
supported_events
.
include?
(
data
[
:object_kind
])
return
unless
object_kind
==
"push"
gate
[
room
].
send
(
'GitLab'
,
create_message
(
data
))
gate
[
room
].
send
(
'GitLab'
,
create_message
(
data
))
end
end
...
...
app/models/project_services/issue_tracker_service.rb
View file @
d57e809c
...
@@ -69,9 +69,12 @@ class IssueTrackerService < Service
...
@@ -69,9 +69,12 @@ class IssueTrackerService < Service
end
end
end
end
def
supported_events
%w(push)
end
def
execute
(
data
)
def
execute
(
data
)
object_kind
=
data
[
:object_kind
]
return
unless
supported_events
.
include?
(
data
[
:object_kind
])
return
unless
object_kind
==
"push"
message
=
"
#{
self
.
type
}
was unable to reach
#{
self
.
project_url
}
. Check the url and try again."
message
=
"
#{
self
.
type
}
was unable to reach
#{
self
.
project_url
}
. Check the url and try again."
result
=
false
result
=
false
...
...
app/models/project_services/pivotaltracker_service.rb
View file @
d57e809c
...
@@ -41,9 +41,12 @@ class PivotaltrackerService < Service
...
@@ -41,9 +41,12 @@ class PivotaltrackerService < Service
]
]
end
end
def
supported_events
%w(push)
end
def
execute
(
data
)
def
execute
(
data
)
object_kind
=
data
[
:object_kind
]
return
unless
supported_events
.
include?
(
data
[
:object_kind
])
return
unless
object_kind
==
"push"
url
=
'https://www.pivotaltracker.com/services/v5/source_commits'
url
=
'https://www.pivotaltracker.com/services/v5/source_commits'
data
[
:commits
].
each
do
|
commit
|
data
[
:commits
].
each
do
|
commit
|
...
...
app/models/project_services/pushover_service.rb
View file @
d57e809c
...
@@ -80,9 +80,12 @@ class PushoverService < Service
...
@@ -80,9 +80,12 @@ class PushoverService < Service
]
]
end
end
def
supported_events
%w(push)
end
def
execute
(
data
)
def
execute
(
data
)
object_kind
=
data
[
:object_kind
]
return
unless
supported_events
.
include?
(
data
[
:object_kind
])
return
unless
object_kind
==
"push"
ref
=
data
[
:ref
].
gsub
(
'refs/heads/'
,
''
)
ref
=
data
[
:ref
].
gsub
(
'refs/heads/'
,
''
)
before
=
data
[
:before
]
before
=
data
[
:before
]
...
...
app/models/project_services/slack_service.rb
View file @
d57e809c
...
@@ -42,7 +42,12 @@ class SlackService < Service
...
@@ -42,7 +42,12 @@ class SlackService < Service
]
]
end
end
def
supported_events
%w(push issue merge_request)
end
def
execute
(
data
)
def
execute
(
data
)
return
unless
supported_events
.
include?
(
data
[
:object_kind
])
return
unless
webhook
.
present?
return
unless
webhook
.
present?
object_kind
=
data
[
:object_kind
]
object_kind
=
data
[
:object_kind
]
...
...
app/models/project_services/teamcity_service.rb
View file @
d57e809c
...
@@ -61,6 +61,10 @@ class TeamcityService < CiService
...
@@ -61,6 +61,10 @@ class TeamcityService < CiService
'teamcity'
'teamcity'
end
end
def
supported_events
%w(push)
end
def
fields
def
fields
[
[
{
type:
'text'
,
name:
'teamcity_url'
,
{
type:
'text'
,
name:
'teamcity_url'
,
...
@@ -120,8 +124,7 @@ class TeamcityService < CiService
...
@@ -120,8 +124,7 @@ class TeamcityService < CiService
end
end
def
execute
(
data
)
def
execute
(
data
)
object_kind
=
data
[
:object_kind
]
return
unless
supported_events
.
include?
(
data
[
:object_kind
])
return
unless
object_kind
==
"push"
auth
=
{
auth
=
{
username:
username
,
username:
username
,
...
...
app/models/service.rb
View file @
d57e809c
...
@@ -80,6 +80,10 @@ class Service < ActiveRecord::Base
...
@@ -80,6 +80,10 @@ class Service < ActiveRecord::Base
[]
[]
end
end
def
supported_events
%w(push tag_push issue merge_request)
end
def
execute
def
execute
# implement inside child
# implement inside child
end
end
...
@@ -105,6 +109,8 @@ class Service < ActiveRecord::Base
...
@@ -105,6 +109,8 @@ class Service < ActiveRecord::Base
end
end
def
async_execute
(
data
)
def
async_execute
(
data
)
return
unless
supported_events
.
include?
(
data
[
:object_kind
])
Sidekiq
::
Client
.
enqueue
(
ProjectServiceWorker
,
id
,
data
)
Sidekiq
::
Client
.
enqueue
(
ProjectServiceWorker
,
id
,
data
)
end
end
...
...
app/views/admin/services/_form.html.haml
View file @
d57e809c
...
@@ -14,6 +14,43 @@
...
@@ -14,6 +14,43 @@
=
preserve
do
=
preserve
do
=
markdown
@service
.
help
=
markdown
@service
.
help
.form-group
=
f
.
label
:url
,
"Trigger"
,
class:
'control-label'
-
if
@service
.
supported_events
.
length
>
1
.col-sm-10
-
if
@service
.
supported_events
.
include?
(
"push"
)
%div
=
f
.
check_box
:push_events
,
class:
'pull-left'
.prepend-left-20
=
f
.
label
:push_events
,
class:
'list-label'
do
%strong
Push events
%p
.light
This url will be triggered by a push to the repository
-
if
@service
.
supported_events
.
include?
(
"tag_push"
)
%div
=
f
.
check_box
:tag_push_events
,
class:
'pull-left'
.prepend-left-20
=
f
.
label
:tag_push_events
,
class:
'list-label'
do
%strong
Tag push events
%p
.light
This url will be triggered when a new tag is pushed to the repository
-
if
@service
.
supported_events
.
include?
(
"issue"
)
%div
=
f
.
check_box
:issues_events
,
class:
'pull-left'
.prepend-left-20
=
f
.
label
:issues_events
,
class:
'list-label'
do
%strong
Issues events
%p
.light
This url will be triggered when an issue is created
-
if
@service
.
supported_events
.
include?
(
"merge_request"
)
%div
=
f
.
check_box
:merge_requests_events
,
class:
'pull-left'
.prepend-left-20
=
f
.
label
:merge_requests_events
,
class:
'list-label'
do
%strong
Merge Request events
%p
.light
This url will be triggered when a merge request is created
-
@service
.
fields
.
each
do
|
field
|
-
@service
.
fields
.
each
do
|
field
|
-
name
=
field
[
:name
]
-
name
=
field
[
:name
]
-
value
=
@service
.
send
(
name
)
unless
field
[
:type
]
==
'password'
-
value
=
@service
.
send
(
name
)
unless
field
[
:type
]
==
'password'
...
...
app/views/projects/services/_form.html.haml
View file @
d57e809c
...
@@ -29,7 +29,9 @@
...
@@ -29,7 +29,9 @@
.form-group
.form-group
=
f
.
label
:url
,
"Trigger"
,
class:
'control-label'
=
f
.
label
:url
,
"Trigger"
,
class:
'control-label'
-
if
@service
.
supported_events
.
length
>
1
.col-sm-10
.col-sm-10
-
if
@service
.
supported_events
.
include?
(
"push"
)
%div
%div
=
f
.
check_box
:push_events
,
class:
'pull-left'
=
f
.
check_box
:push_events
,
class:
'pull-left'
.prepend-left-20
.prepend-left-20
...
@@ -37,6 +39,7 @@
...
@@ -37,6 +39,7 @@
%strong
Push events
%strong
Push events
%p
.light
%p
.light
This url will be triggered by a push to the repository
This url will be triggered by a push to the repository
-
if
@service
.
supported_events
.
include?
(
"tag_push"
)
%div
%div
=
f
.
check_box
:tag_push_events
,
class:
'pull-left'
=
f
.
check_box
:tag_push_events
,
class:
'pull-left'
.prepend-left-20
.prepend-left-20
...
@@ -44,6 +47,7 @@
...
@@ -44,6 +47,7 @@
%strong
Tag push events
%strong
Tag push events
%p
.light
%p
.light
This url will be triggered when a new tag is pushed to the repository
This url will be triggered when a new tag is pushed to the repository
-
if
@service
.
supported_events
.
include?
(
"issue"
)
%div
%div
=
f
.
check_box
:issues_events
,
class:
'pull-left'
=
f
.
check_box
:issues_events
,
class:
'pull-left'
.prepend-left-20
.prepend-left-20
...
@@ -51,6 +55,7 @@
...
@@ -51,6 +55,7 @@
%strong
Issues events
%strong
Issues events
%p
.light
%p
.light
This url will be triggered when an issue is created
This url will be triggered when an issue is created
-
if
@service
.
supported_events
.
include?
(
"merge_request"
)
%div
%div
=
f
.
check_box
:merge_requests_events
,
class:
'pull-left'
=
f
.
check_box
:merge_requests_events
,
class:
'pull-left'
.prepend-left-20
.prepend-left-20
...
...
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