Commit 2f418b77 authored by Matija Čupić's avatar Matija Čupić

Protect against triggering invalid build actions

parent ca92c9ac
...@@ -5,6 +5,8 @@ module EE ...@@ -5,6 +5,8 @@ module EE
module Bridge module Bridge
extend ActiveSupport::Concern extend ActiveSupport::Concern
InvalidBridgeTypeError = Class.new(StandardError)
prepended do prepended do
include ::Ci::Metadatable include ::Ci::Metadatable
...@@ -35,10 +37,14 @@ module EE ...@@ -35,10 +37,14 @@ module EE
end end
def schedule_downstream_pipeline! def schedule_downstream_pipeline!
raise InvalidBridgeTypeError unless downstream_project
::Ci::CreateCrossProjectPipelineWorker.perform_async(self.id) ::Ci::CreateCrossProjectPipelineWorker.perform_async(self.id)
end end
def subscribe_to_upstream! def subscribe_to_upstream!
raise InvalidBridgeTypeError unless upstream_project
::Ci::SubscribeBridgeService.new(self.project, self.user).execute(self) ::Ci::SubscribeBridgeService.new(self.project, self.user).execute(self)
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment