2014-09-02 18:07:02 +05:30
|
|
|
require "flowdock-git-hook"
|
|
|
|
|
|
|
|
class FlowdockService < Service
|
2015-04-26 12:48:37 +05:30
|
|
|
prop_accessor :token
|
2014-09-02 18:07:02 +05:30
|
|
|
validates :token, presence: true, if: :activated?
|
|
|
|
|
|
|
|
def title
|
|
|
|
'Flowdock'
|
|
|
|
end
|
|
|
|
|
|
|
|
def description
|
|
|
|
'Flowdock is a collaboration web app for technical teams.'
|
|
|
|
end
|
|
|
|
|
|
|
|
def to_param
|
|
|
|
'flowdock'
|
|
|
|
end
|
|
|
|
|
|
|
|
def fields
|
|
|
|
[
|
2015-09-11 14:41:01 +05:30
|
|
|
{ type: 'text', name: 'token', placeholder: 'Flowdock Git source token' }
|
2014-09-02 18:07:02 +05:30
|
|
|
]
|
|
|
|
end
|
|
|
|
|
2015-04-26 12:48:37 +05:30
|
|
|
def supported_events
|
|
|
|
%w(push)
|
|
|
|
end
|
|
|
|
|
|
|
|
def execute(data)
|
|
|
|
return unless supported_events.include?(data[:object_kind])
|
|
|
|
|
2014-09-02 18:07:02 +05:30
|
|
|
Flowdock::Git.post(
|
2015-04-26 12:48:37 +05:30
|
|
|
data[:ref],
|
|
|
|
data[:before],
|
|
|
|
data[:after],
|
2014-09-02 18:07:02 +05:30
|
|
|
token: token,
|
2015-04-26 12:48:37 +05:30
|
|
|
repo: project.repository.path_to_repo,
|
2014-09-02 18:07:02 +05:30
|
|
|
repo_url: "#{Gitlab.config.gitlab.url}/#{project.path_with_namespace}",
|
|
|
|
commit_url: "#{Gitlab.config.gitlab.url}/#{project.path_with_namespace}/commit/%s",
|
|
|
|
diff_url: "#{Gitlab.config.gitlab.url}/#{project.path_with_namespace}/compare/%s...%s",
|
2015-12-23 02:04:40 +05:30
|
|
|
)
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
|
|
|
end
|