summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJason Goodman <jgoodman@gitlab.com>2019-04-26 21:08:41 +0000
committerDouglas Barbosa Alexandre <dbalexandre@gmail.com>2019-04-26 21:08:41 +0000
commitfe86890b9d7a720648e7570d227c438d6ca7f25a (patch)
tree1c583b22cea6404de37ae6217f320d93cdf7cde9 /lib
parent265b789476479c29ea88db174aca1d80ddf24358 (diff)
downloadgitlab-ce-fe86890b9d7a720648e7570d227c438d6ca7f25a.tar.gz
Add deployment events to chat notification services
This enables sending a chat message to Slack or Mattermost upon a successful, failed, or canceled deployment
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/data_builder/deployment.rb23
-rw-r--r--lib/gitlab/url_builder.rb2
2 files changed, 25 insertions, 0 deletions
diff --git a/lib/gitlab/data_builder/deployment.rb b/lib/gitlab/data_builder/deployment.rb
new file mode 100644
index 00000000000..26705dd1f6f
--- /dev/null
+++ b/lib/gitlab/data_builder/deployment.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+module Gitlab
+ module DataBuilder
+ module Deployment
+ extend self
+
+ def build(deployment)
+ {
+ object_kind: 'deployment',
+ status: deployment.status,
+ deployable_id: deployment.deployable_id,
+ deployable_url: Gitlab::UrlBuilder.build(deployment.deployable),
+ environment: deployment.environment.name,
+ project: deployment.project.hook_attrs,
+ short_sha: deployment.short_sha,
+ user: deployment.user.hook_attrs,
+ commit_url: Gitlab::UrlBuilder.build(deployment.commit)
+ }
+ end
+ end
+ end
+end
diff --git a/lib/gitlab/url_builder.rb b/lib/gitlab/url_builder.rb
index f86d599e4cb..169ce8ab026 100644
--- a/lib/gitlab/url_builder.rb
+++ b/lib/gitlab/url_builder.rb
@@ -30,6 +30,8 @@ module Gitlab
snippet_url(object)
when Milestone
milestone_url(object)
+ when ::Ci::Build
+ project_job_url(object.project, object)
else
raise NotImplementedError.new("No URL builder defined for #{object.class}")
end