plugin.rb 616 Bytes
Newer Older
1 2
# frozen_string_literal: true

3 4
module Gitlab
  module Plugin
5
    def self.files
6 7 8
      Dir.glob(Rails.root.join('plugins/*')).select do |entry|
        File.file?(entry)
      end
9
    end
10

11
    def self.execute_all_async(data)
12 13 14
      args = files.map { |file| [file, data] }

      PluginWorker.bulk_perform_async(args)
15 16
    end

17
    def self.execute(file, data)
18
      result = Gitlab::Popen.popen_with_detail([file]) do |stdin|
19
        stdin.write(data.to_json)
20 21
      end

22
      exit_status = result.status&.exitstatus
23
      [exit_status.zero?, result.stderr]
24
    rescue => e
25
      [false, e.message]
26 27 28
    end
  end
end