Sha256: 56237a56e75a5ae20e8fb2fd42797b77dbb0a3bd79d9958d6379f47d8ec65f64

Contents?: true

Size: 1.79 KB

Versions: 1

Compression:

Stored size: 1.79 KB

Contents

require 'json'
require 'KCommercialPipeline/App'
# {
#     "kim": {
#         "AutoRelease": {
#             "robot_key": [],
#             "mentioned_list": []
#         },
#         "FeatureSend": {
#             "robot_key": ["xxxxxx","xxxxxx"],
#             "mentioned_list": ["hzx","hhh"],
#             "regular": "^(\\[[a-zA-Z0-9]+\\])?feat(\\(.*\\))?:.*"
#         },
#         "ReleaseCheck": {
#             "robot_key": [],
#             "mentioned_list": []
#         },
#         "AutoCherryPick":{
#           "robot_key": [],
#           "mentioned_list": []
#         }
#
#     }
# }

module KCommercial
  module KCPipeline
    module KimConfig
      class << self
        def  configs
          @configs ||= readConfig
        end
        def readConfig
          cfg_path= find_cfg_path
          unless  cfg_path
            KCommercial::UI.error("根目录未发现pipeline配置文件\".pipeline\"")
            exit! 1
          end
          KCommercial::UI.debug("读取pipeline配置文件")
          cfg_hash = JSON.parse(File.read(cfg_path))
          KCommercial::UI.debug("pipeline配置#{cfg_hash.to_s}")
          return {} unless cfg_hash
          unless  cfg_hash[Application.instance.app_id]
            KCommercial::UI.error("未配置app=#{Application.instance.app_id}流水线配置 `.pipeline`文件,请检查根目录")
            exit! -1
          end
          cfg_hash[Application.instance.app_id]
        end

        def find_cfg_path(path = Pathname(Dir.pwd))
          find_path = Pathname(path)
          while find_path.parent.to_s != '/' || find_path.to_s != '/'
            aim_path = find_path.join('.pipeline')
            return aim_path if aim_path.exist?
            find_path = find_path.parent
          end
          return nil
        end
      end

    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
KCommercialPipeline-0.2.5.1 lib/KCommercialPipeline/core/kim_cfg.rb