summaryrefslogtreecommitdiff
path: root/app/models/deployment.rb
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 /app/models/deployment.rb
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 'app/models/deployment.rb')
-rw-r--r--app/models/deployment.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/app/models/deployment.rb b/app/models/deployment.rb
index d847a0a11e4..f5fdf285522 100644
--- a/app/models/deployment.rb
+++ b/app/models/deployment.rb
@@ -47,6 +47,12 @@ class Deployment < ApplicationRecord
Deployments::SuccessWorker.perform_async(id)
end
end
+
+ after_transition any => [:success, :failed, :canceled] do |deployment|
+ deployment.run_after_commit do
+ Deployments::FinishedWorker.perform_async(id)
+ end
+ end
end
enum status: {
@@ -82,6 +88,11 @@ class Deployment < ApplicationRecord
project.deployment_platform(environment: environment.name)&.cluster
end
+ def execute_hooks
+ deployment_data = Gitlab::DataBuilder::Deployment.build(self)
+ project.execute_services(deployment_data, :deployment_hooks)
+ end
+
def last?
self == environment.last_deployment
end