Class: Fastlane::Helper::GsProjectFlowIosHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/fastlane/plugin/gs_project_flow_ios/helper/gs_project_flow_ios_helper.rb

Defined Under Namespace

Modules: BuildState

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.get_versions_pathObject

class methods that you define here become available in your action as ‘Helper::GsProjectFlowIosHelper.your_method`



29
30
31
# File 'lib/fastlane/plugin/gs_project_flow_ios/helper/gs_project_flow_ios_helper.rb', line 29

def self.get_versions_path
  return Dir.pwd+"/../../versions.json"
end

.send_report(message, buildState, lane, restartBuildURL = nil) ⇒ Object



106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/fastlane/plugin/gs_project_flow_ios/helper/gs_project_flow_ios_helper.rb', line 106

def self.send_report(message, buildState, lane, restartBuildURL = nil)
  # Dir.chdir Dir.pwd+"/../../../../" do
  UI.message(Dir.pwd)
  params = Hash.new
  params["state"] = buildState
  params["alias"] = ENV["ALIAS"]

  if buildState == BuildState::FAILURE
    params["message"] = message
  end
  if restartBuildURL != nil
    params["restart_build_url"] = restartBuildURL
  end

  if lane == :beta
    params["cmd"] = "beta"
  elsif lane == :rc
    params["cmd"] = "rc"
  elsif lane == :release
    params["cmd"] = "release"
  end



  paramsJSON = params.to_json


  client = Spaceship::GSBotClient.new
  url = 'jobStates'
  response = client.request(:post) do |req|
    req.url url
    req.body = paramsJSON
    req.headers['Content-Type'] = 'application/json'
  end
  UI.important('body ' + paramsJSON)
  if response.success?
    UI.important('status' + response.status.to_s)
    return response
  else
    raise (client.class.hostname + url + ' ' + response.status.to_s + ' ' + response.body['message'])
  end


    # Actions::ShAction.run(FastlaneCore::Configuration.create(Actions::ShAction.available_options,
    #                                                          {command:"curl -X POST -H \"Content-Type: application/json\" -d '#{paramsJSON}' http://mobile.geo4.io/bot/releaseBuilder/jobStates"}))
    # sh "sh build_reporter.sh " + chat_id.to_s + " " + message
  # end
end

.show_messageObject



155
156
157
# File 'lib/fastlane/plugin/gs_project_flow_ios/helper/gs_project_flow_ios_helper.rb', line 155

def self.show_message
  UI.message("Hello from the gs_project_flow_ios plugin helper!")
end

.version_for_lane(lane, buildState) ⇒ Object



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/fastlane/plugin/gs_project_flow_ios/helper/gs_project_flow_ios_helper.rb', line 67

def self.version_for_lane(lane, buildState)
  version_name = ""
  if lane == :beta
    if buildState == BuildState::FAILURE
      v = Actions::GsIncrementBetaVersionAction.run(FastlaneCore::Configuration.create(Actions::GsIncrementBetaVersionAction.available_options,{path: GsProjectFlowIosHelper.get_versions_path}))
    else
      v = Actions::GsGetBetaVersionAction.run(FastlaneCore::Configuration.create(Actions::GsGetBetaVersionAction.available_options,{path: GsProjectFlowIosHelper.get_versions_path}))
    end

    version_name = v.major.to_s+ "." + v.minor.to_s + "." + v.build.to_s
  elsif lane == :rc
    if buildState == BuildState::FAILURE
      if ENV['RC_DID_FAILED'] #Если произошла ошибка до успешной отправки в стор
        v = Actions::GsIncrementRcVersionAction.run(FastlaneCore::Configuration.create(Actions::GsIncrementBetaVersionAction.available_options,{path: GsProjectFlowIosHelper.get_versions_path}))
      else
        v = Actions::GsGetRcVersionAction.run(FastlaneCore::Configuration.create(Actions::GsGetBetaVersionAction.available_options,{path: GsProjectFlowIosHelper.get_versions_path}))
      end
    else
      v = Actions::GsGetRcVersionAction.run(FastlaneCore::Configuration.create(Actions::GsGetBetaVersionAction.available_options,{path: GsProjectFlowIosHelper.get_versions_path}))
    end
    # v = gs_get_rc_version(path: GsProjectFlowIosHelper.get_versions_path)
    version_name = v.major.to_s+ "." + v.minor.to_s
  elsif lane == :release
    if buildState == BuildState::FAILURE
      v = Actions::GsIncrementReleaseVersionAction.run(FastlaneCore::Configuration.create(Actions::GsIncrementBetaVersionAction.available_options,{path: GsProjectFlowIosHelper.get_versions_path}))
    else
      v = Actions::GsGetReleaseVersionAction.run(FastlaneCore::Configuration.create(Actions::GsGetBetaVersionAction.available_options,{path: GsProjectFlowIosHelper.get_versions_path}))
    end
    # v = gs_get_release_version(path: GsProjectFlowIosHelper.get_versions_path)
    version_name = v.major.to_s+ "." + v.minor.to_s
  end
  return version_name,v
end

Instance Method Details

#execute_action(action, parameters, class_ref: nil, custom_dir: '.', from_action: false) ⇒ Object



33
34
35
36
37
38
39
40
41
# File 'lib/fastlane/plugin/gs_project_flow_ios/helper/gs_project_flow_ios_helper.rb', line 33

def execute_action(action, parameters, class_ref: nil, custom_dir: '.', from_action: false)
  if class_ref.nil?
    local_class_ref = Actions.action_class_ref(action)
  else
    local_class_ref = class_ref
  end
  r = Runner.new
  r.execute_action(action, local_class_ref, [parameters], custom_dir: custom_dir, from_action: from_action)
end

#generateReleaseNotes(cmd, aliasServer, version, lang = nil) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/fastlane/plugin/gs_project_flow_ios/helper/gs_project_flow_ios_helper.rb', line 43

def generateReleaseNotes(cmd,  aliasServer, version, lang = nil)
  cmnd = cmd
  if lang != nil
    cmnd = cmnd+lang
  else
    raise "Language is required for release notes generating."
  end
  require 'fastlane/plugin/gs_deliver'
  # params = {cmd:cmnd,
  #           lang: lang,
  #           alias:aliasServer,
  #           displayVersionName:version}
  # text = execute_action('gs_get_release_notes', params)
  text = Actions::GsGetReleaseNotesAction.run(FastlaneCore::Configuration.create(Actions::GsGetReleaseNotesAction.available_options,{cmd:cmnd,
                       lang: lang,
                       alias:aliasServer,
                       displayVersionName:version}))
  # UI.message("Check exist " + Dir.pwd + "/../../../notes/" + aliasServer + "/" + version + "_" + lang + ".txt")
  # if !File.exist?(Dir.pwd + "/../../../notes/" + aliasServer + "/" + version + "_" + lang + ".txt")
  #   raise "Не удалось сгенерировать ReleaseNotes"
  # end
  return text
end