2018-02-19 17:20:53 +00:00
|
|
|
module Gitlab
|
|
|
|
module Plugin
|
2018-02-19 17:55:54 +00:00
|
|
|
def self.files
|
2018-02-26 11:32:14 +00:00
|
|
|
Dir.glob(Rails.root.join('plugins/*')).select do |entry|
|
|
|
|
File.file?(entry)
|
|
|
|
end
|
2018-02-19 17:55:54 +00:00
|
|
|
end
|
2018-02-19 17:20:53 +00:00
|
|
|
|
2018-02-19 17:55:54 +00:00
|
|
|
def self.execute_all_async(data)
|
2018-02-26 12:15:51 +00:00
|
|
|
args = files.map { |file| [file, data] }
|
|
|
|
|
|
|
|
PluginWorker.bulk_perform_async(args)
|
2018-02-19 17:20:53 +00:00
|
|
|
end
|
|
|
|
|
2018-02-19 17:55:54 +00:00
|
|
|
def self.execute(file, data)
|
2018-02-27 16:08:38 +00:00
|
|
|
result = Gitlab::Popen.popen_with_detail([file]) do |stdin|
|
2018-02-26 11:42:25 +00:00
|
|
|
stdin.write(data.to_json)
|
2018-02-23 13:58:57 +00:00
|
|
|
end
|
|
|
|
|
2018-02-27 16:08:38 +00:00
|
|
|
exit_status = result.status&.exitstatus
|
2018-02-28 10:16:23 +00:00
|
|
|
[exit_status.zero?, result.stderr]
|
2018-02-27 16:08:38 +00:00
|
|
|
rescue => e
|
2018-02-28 10:16:23 +00:00
|
|
|
[false, e.message]
|
2018-02-19 17:20:53 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|