Set supported events per project service.
This commit is contained in:
parent
85fa334eb6
commit
d57e809cbd
19 changed files with 156 additions and 57 deletions
|
@ -65,9 +65,12 @@ automatically inspected. Leave blank to include all branches.'
|
|||
]
|
||||
end
|
||||
|
||||
def supported_events
|
||||
%w(push)
|
||||
end
|
||||
|
||||
def execute(data)
|
||||
object_kind = data[:object_kind]
|
||||
return unless object_kind == "push"
|
||||
return unless supported_events.include?(data[:object_kind])
|
||||
|
||||
Asana.configure do |client|
|
||||
client.api_key = api_key
|
||||
|
|
|
@ -42,9 +42,12 @@ class AssemblaService < Service
|
|||
]
|
||||
end
|
||||
|
||||
def supported_events
|
||||
%w(push)
|
||||
end
|
||||
|
||||
def execute(data)
|
||||
object_kind = data[:object_kind]
|
||||
return unless object_kind == "push"
|
||||
return unless supported_events.include?(data[:object_kind])
|
||||
|
||||
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' })
|
||||
|
|
|
@ -73,6 +73,10 @@ class BambooService < CiService
|
|||
]
|
||||
end
|
||||
|
||||
def supported_events
|
||||
%w(push)
|
||||
end
|
||||
|
||||
def build_info(sha)
|
||||
url = URI.parse("#{bamboo_url}/rest/api/latest/result?label=#{sha}")
|
||||
|
||||
|
@ -123,8 +127,7 @@ class BambooService < CiService
|
|||
end
|
||||
|
||||
def execute(data)
|
||||
object_kind = data[:object_kind]
|
||||
return unless object_kind == "push"
|
||||
return unless supported_events.include?(data[:object_kind])
|
||||
|
||||
# Bamboo requires a GET and does not take any data.
|
||||
self.class.get("#{bamboo_url}/updateAndBuild.action?buildKey=#{build_key}",
|
||||
|
|
|
@ -36,9 +36,12 @@ class BuildboxService < CiService
|
|||
hook.save
|
||||
end
|
||||
|
||||
def supported_events
|
||||
%w(push)
|
||||
end
|
||||
|
||||
def execute(data)
|
||||
object_kind = data[:object_kind]
|
||||
return unless object_kind == "push"
|
||||
return unless supported_events.include?(data[:object_kind])
|
||||
|
||||
service_hook.execute(data)
|
||||
end
|
||||
|
|
|
@ -41,9 +41,12 @@ class CampfireService < Service
|
|||
]
|
||||
end
|
||||
|
||||
def supported_events
|
||||
%w(push)
|
||||
end
|
||||
|
||||
def execute(data)
|
||||
object_kind = data[:object_kind]
|
||||
return unless object_kind == "push"
|
||||
return unless supported_events.include?(data[:object_kind])
|
||||
|
||||
room = gate.find_room_by_name(self.room)
|
||||
return true unless room
|
||||
|
|
|
@ -25,6 +25,10 @@ class CiService < Service
|
|||
:ci
|
||||
end
|
||||
|
||||
def supported_events
|
||||
%w(push)
|
||||
end
|
||||
|
||||
# Return complete url to build page
|
||||
#
|
||||
# Ex.
|
||||
|
|
|
@ -33,9 +33,12 @@ class EmailsOnPushService < Service
|
|||
'emails_on_push'
|
||||
end
|
||||
|
||||
def supported_events
|
||||
%w(push)
|
||||
end
|
||||
|
||||
def execute(data)
|
||||
object_kind = data[:object_kind]
|
||||
return unless object_kind == "push"
|
||||
return unless supported_events.include?(data[:object_kind])
|
||||
|
||||
EmailsOnPushWorker.perform_async(project_id, recipients, data)
|
||||
end
|
||||
|
|
|
@ -41,9 +41,12 @@ class FlowdockService < Service
|
|||
]
|
||||
end
|
||||
|
||||
def supported_events
|
||||
%w(push)
|
||||
end
|
||||
|
||||
def execute(data)
|
||||
object_kind = data[:object_kind]
|
||||
return unless object_kind == "push"
|
||||
return unless supported_events.include?(data[:object_kind])
|
||||
|
||||
Flowdock::Git.post(
|
||||
data[:ref],
|
||||
|
|
|
@ -42,9 +42,12 @@ class GemnasiumService < Service
|
|||
]
|
||||
end
|
||||
|
||||
def supported_events
|
||||
%w(push)
|
||||
end
|
||||
|
||||
def execute(data)
|
||||
object_kind = data[:object_kind]
|
||||
return unless object_kind == "push"
|
||||
return unless supported_events.include?(data[:object_kind])
|
||||
|
||||
Gemnasium::GitlabService.execute(
|
||||
ref: data[:ref],
|
||||
|
|
|
@ -30,9 +30,12 @@ class GitlabCiService < CiService
|
|||
hook.save
|
||||
end
|
||||
|
||||
def supported_events
|
||||
%w(push tag_push)
|
||||
end
|
||||
|
||||
def execute(data)
|
||||
object_kind = data[:object_kind]
|
||||
return unless %w(push tag_push).include?(object_kind)
|
||||
return unless supported_events.include?(data[:object_kind])
|
||||
|
||||
service_hook.execute(data)
|
||||
end
|
||||
|
|
|
@ -44,9 +44,12 @@ class HipchatService < Service
|
|||
]
|
||||
end
|
||||
|
||||
def supported_events
|
||||
%w(push)
|
||||
end
|
||||
|
||||
def execute(data)
|
||||
object_kind = data[:object_kind]
|
||||
return unless object_kind == "push"
|
||||
return unless supported_events.include?(data[:object_kind])
|
||||
|
||||
gate[room].send('GitLab', create_message(data))
|
||||
end
|
||||
|
|
|
@ -69,9 +69,12 @@ class IssueTrackerService < Service
|
|||
end
|
||||
end
|
||||
|
||||
def supported_events
|
||||
%w(push)
|
||||
end
|
||||
|
||||
def execute(data)
|
||||
object_kind = data[:object_kind]
|
||||
return unless object_kind == "push"
|
||||
return unless supported_events.include?(data[:object_kind])
|
||||
|
||||
message = "#{self.type} was unable to reach #{self.project_url}. Check the url and try again."
|
||||
result = false
|
||||
|
|
|
@ -41,9 +41,12 @@ class PivotaltrackerService < Service
|
|||
]
|
||||
end
|
||||
|
||||
def supported_events
|
||||
%w(push)
|
||||
end
|
||||
|
||||
def execute(data)
|
||||
object_kind = data[:object_kind]
|
||||
return unless object_kind == "push"
|
||||
return unless supported_events.include?(data[:object_kind])
|
||||
|
||||
url = 'https://www.pivotaltracker.com/services/v5/source_commits'
|
||||
data[:commits].each do |commit|
|
||||
|
|
|
@ -80,9 +80,12 @@ class PushoverService < Service
|
|||
]
|
||||
end
|
||||
|
||||
def supported_events
|
||||
%w(push)
|
||||
end
|
||||
|
||||
def execute(data)
|
||||
object_kind = data[:object_kind]
|
||||
return unless object_kind == "push"
|
||||
return unless supported_events.include?(data[:object_kind])
|
||||
|
||||
ref = data[:ref].gsub('refs/heads/', '')
|
||||
before = data[:before]
|
||||
|
|
|
@ -42,7 +42,12 @@ class SlackService < Service
|
|||
]
|
||||
end
|
||||
|
||||
def supported_events
|
||||
%w(push issue merge_request)
|
||||
end
|
||||
|
||||
def execute(data)
|
||||
return unless supported_events.include?(data[:object_kind])
|
||||
return unless webhook.present?
|
||||
|
||||
object_kind = data[:object_kind]
|
||||
|
|
|
@ -61,6 +61,10 @@ class TeamcityService < CiService
|
|||
'teamcity'
|
||||
end
|
||||
|
||||
def supported_events
|
||||
%w(push)
|
||||
end
|
||||
|
||||
def fields
|
||||
[
|
||||
{ type: 'text', name: 'teamcity_url',
|
||||
|
@ -120,8 +124,7 @@ class TeamcityService < CiService
|
|||
end
|
||||
|
||||
def execute(data)
|
||||
object_kind = data[:object_kind]
|
||||
return unless object_kind == "push"
|
||||
return unless supported_events.include?(data[:object_kind])
|
||||
|
||||
auth = {
|
||||
username: username,
|
||||
|
|
|
@ -80,6 +80,10 @@ class Service < ActiveRecord::Base
|
|||
[]
|
||||
end
|
||||
|
||||
def supported_events
|
||||
%w(push tag_push issue merge_request)
|
||||
end
|
||||
|
||||
def execute
|
||||
# implement inside child
|
||||
end
|
||||
|
@ -105,6 +109,8 @@ class Service < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def async_execute(data)
|
||||
return unless supported_events.include?(data[:object_kind])
|
||||
|
||||
Sidekiq::Client.enqueue(ProjectServiceWorker, id, data)
|
||||
end
|
||||
|
||||
|
|
|
@ -14,6 +14,43 @@
|
|||
= preserve do
|
||||
= 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|
|
||||
- name = field[:name]
|
||||
- value = @service.send(name) unless field[:type] == 'password'
|
||||
|
|
|
@ -29,7 +29,9 @@
|
|||
|
||||
.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
|
||||
|
@ -37,6 +39,7 @@
|
|||
%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
|
||||
|
@ -44,6 +47,7 @@
|
|||
%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
|
||||
|
@ -51,6 +55,7 @@
|
|||
%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
|
||||
|
|
Loading…
Reference in a new issue