summaryrefslogtreecommitdiff
path: root/app/models/ci/pipeline.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/ci/pipeline.rb')
-rw-r--r--app/models/ci/pipeline.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb
index 8cfba92ae9b..130afeb724e 100644
--- a/app/models/ci/pipeline.rb
+++ b/app/models/ci/pipeline.rb
@@ -19,6 +19,8 @@ module Ci
after_save :keep_around_commits
+ delegate :stages, to: :statuses
+
state_machine :status, initial: :created do
event :enqueue do
transition created: :pending
@@ -56,6 +58,10 @@ module Ci
before_transition do |pipeline|
pipeline.update_duration
end
+
+ after_transition do |pipeline, transition|
+ pipeline.execute_hooks unless transition.loopback?
+ end
end
# ref can't be HEAD or SHA, can only be branch/tag name
@@ -243,8 +249,18 @@ module Ci
self.duration = statuses.latest.duration
end
+ def execute_hooks
+ data = pipeline_data
+ project.execute_hooks(data, :pipeline_hooks)
+ project.execute_services(data, :pipeline_hooks)
+ end
+
private
+ def pipeline_data
+ Gitlab::DataBuilder::Pipeline.build(self)
+ end
+
def latest_builds_status
return 'failed' unless yaml_errors.blank?