From 9be0c2734ae3e3cc84196cf167a0c327c7cf8570 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 8 Feb 2018 17:51:02 +0200 Subject: Add external plugins support to extend system hooks Signed-off-by: Dmitriy Zaporozhets --- app/services/system_hooks_service.rb | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'app') diff --git a/app/services/system_hooks_service.rb b/app/services/system_hooks_service.rb index a6b7a6e1416..71de74e5a82 100644 --- a/app/services/system_hooks_service.rb +++ b/app/services/system_hooks_service.rb @@ -11,6 +11,15 @@ class SystemHooksService SystemHook.hooks_for(hooks_scope).find_each do |hook| hook.async_execute(data, 'system_hooks') end + + # Execute external plugins + PLUGINS.each do |plugin| + begin + plugin.new.execute(data) + rescue => e + Rails.logger.warn("GitLab -> Plugins -> #{plugin.class.name} raised an axception during execution. #{e}") + end + end end private -- cgit v1.2.3 From 5bb435d0e75ad84e2fc379208cc36a25a4574453 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 19 Feb 2018 19:20:53 +0200 Subject: Remove plugin initializer and add plugins:validate rake task Signed-off-by: Dmitriy Zaporozhets --- app/services/system_hooks_service.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app') diff --git a/app/services/system_hooks_service.rb b/app/services/system_hooks_service.rb index 71de74e5a82..ba46c0074e4 100644 --- a/app/services/system_hooks_service.rb +++ b/app/services/system_hooks_service.rb @@ -13,7 +13,7 @@ class SystemHooksService end # Execute external plugins - PLUGINS.each do |plugin| + Gitlab::Plugin.all.each do |plugin| begin plugin.new.execute(data) rescue => e -- cgit v1.2.3 From eff5746b5e7cf4075edd6d1c76fdcd24c1603bb4 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 19 Feb 2018 19:55:54 +0200 Subject: Redesign plugins system Signed-off-by: Dmitriy Zaporozhets --- app/services/system_hooks_service.rb | 9 +-------- app/workers/plugin_worker.rb | 9 +++++++++ 2 files changed, 10 insertions(+), 8 deletions(-) create mode 100644 app/workers/plugin_worker.rb (limited to 'app') diff --git a/app/services/system_hooks_service.rb b/app/services/system_hooks_service.rb index ba46c0074e4..af8c02a10b7 100644 --- a/app/services/system_hooks_service.rb +++ b/app/services/system_hooks_service.rb @@ -12,14 +12,7 @@ class SystemHooksService hook.async_execute(data, 'system_hooks') end - # Execute external plugins - Gitlab::Plugin.all.each do |plugin| - begin - plugin.new.execute(data) - rescue => e - Rails.logger.warn("GitLab -> Plugins -> #{plugin.class.name} raised an axception during execution. #{e}") - end - end + Gitlab::Plugin.execute_all_async(data) end private diff --git a/app/workers/plugin_worker.rb b/app/workers/plugin_worker.rb new file mode 100644 index 00000000000..34a3c8d62ac --- /dev/null +++ b/app/workers/plugin_worker.rb @@ -0,0 +1,9 @@ +class PluginWorker + include ApplicationWorker + + sidekiq_options retry: false + + def perform(file_name, data) + Gitlab::Plugin.execute(file_name, data) + end +end -- cgit v1.2.3 From 3073f1aa6e8658825af739440f7288deeef9169d Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 26 Feb 2018 16:57:10 +0200 Subject: Handle excpetion in PluginWorker Signed-off-by: Dmitriy Zaporozhets --- app/workers/plugin_worker.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'app') diff --git a/app/workers/plugin_worker.rb b/app/workers/plugin_worker.rb index 34a3c8d62ac..cebdf8d0017 100644 --- a/app/workers/plugin_worker.rb +++ b/app/workers/plugin_worker.rb @@ -5,5 +5,7 @@ class PluginWorker def perform(file_name, data) Gitlab::Plugin.execute(file_name, data) + rescue => e + Rails.logger.error("#{self.class}: #{e.message}") end end -- cgit v1.2.3 From 79d911204ca92c759b696d0b8db8e8d54af6e2f9 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 26 Feb 2018 18:17:17 +0200 Subject: Add plugin queue to all_queues.yml Signed-off-by: Dmitriy Zaporozhets --- app/workers/all_queues.yml | 1 + 1 file changed, 1 insertion(+) (limited to 'app') diff --git a/app/workers/all_queues.yml b/app/workers/all_queues.yml index 28a5e5da037..a9415410f8a 100644 --- a/app/workers/all_queues.yml +++ b/app/workers/all_queues.yml @@ -84,6 +84,7 @@ - new_note - pages - pages_domain_verification +- plugin - post_receive - process_commit - project_cache -- cgit v1.2.3 From f0a64399c1171d2757c8ce70a36517d556cd9233 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 27 Feb 2018 18:08:38 +0200 Subject: Refactor plugin execution method Signed-off-by: Dmitriy Zaporozhets --- app/workers/plugin_worker.rb | 2 -- 1 file changed, 2 deletions(-) (limited to 'app') diff --git a/app/workers/plugin_worker.rb b/app/workers/plugin_worker.rb index cebdf8d0017..34a3c8d62ac 100644 --- a/app/workers/plugin_worker.rb +++ b/app/workers/plugin_worker.rb @@ -5,7 +5,5 @@ class PluginWorker def perform(file_name, data) Gitlab::Plugin.execute(file_name, data) - rescue => e - Rails.logger.error("#{self.class}: #{e.message}") end end -- cgit v1.2.3 From 2577ff7fd656f301c4b1909f0a1c358c8c30a614 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 28 Feb 2018 12:16:23 +0200 Subject: Refactor plugins feature and make some doc improvements Signed-off-by: Dmitriy Zaporozhets --- app/workers/plugin_worker.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/workers/plugin_worker.rb b/app/workers/plugin_worker.rb index 34a3c8d62ac..bfcc683d99a 100644 --- a/app/workers/plugin_worker.rb +++ b/app/workers/plugin_worker.rb @@ -4,6 +4,12 @@ class PluginWorker sidekiq_options retry: false def perform(file_name, data) - Gitlab::Plugin.execute(file_name, data) + success, message = Gitlab::Plugin.execute(file_name, data) + + unless success + Gitlab::PluginLogger.error("Plugin Error => #{file_name}: #{message}") + end + + true end end -- cgit v1.2.3