Class: YKCitool::YKFastlaneExecute

Inherits:
Object
  • Object
show all
Defined in:
lib/actions/YKFastlaneExecute.rb

Class Method Summary collapse

Class Method Details

.exchangOptionMapToStr(optionHash) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/actions/YKFastlaneExecute.rb', line 51

def self.exchangOptionMapToStr(optionHash)
  paras = {}
  optionHash.each_pair { |k, v| paras[k] = v }
  puts "paras:#{paras.dup}"

  puts "YKRUNING_PATH:#{Helper::YKRUNING_PATH}"
  workspace_path = Helper::YKRUNING_PATH
  workspace_path = paras["xcworkspace"] unless paras["xcworkspace"].blank?
  paras[:xcworkspace] = workspace_path
  paras[:script_run_path] = Helper::YKRUNING_PATH

  puts "options_after:#{paras}"
  option_str = ""
  paras.each_pair do |k, v|
    option_str << " #{k}:\"#{v}\""
  end
  option_str
end

.executeCommand(commandShell_pre, commandShell, workTitle) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/actions/YKFastlaneExecute.rb', line 24

def self.executeCommand(commandShell_pre, commandShell, workTitle)
  excuteStr = " "
  excuteStr << "#{commandShell_pre}" unless commandShell_pre.blank?
  excuteStr << " && #{commandShell}" unless commandShell.blank?

  puts "START COMMAND:#{excuteStr}"
  code = 1
  system(excuteStr)
  result = $?
  puts "command result[#{result.class}]:#{result}"
  code = result.exitstatus if result.is_a?(Process::Status)

  #### 以下代码注释,因为fastlane脚本中做了任务失败时候的通知
  # if code != 0
  #   #任务失败, 此处需要发送企业微信的通知到开发群
  #   puts "should report error to developer group"
  #   noticeCmd = commandShell_pre
  #   commandShell = commandShell.gsub!( " ", "\\ " )
  #   commandShell = commandShell.gsub!( "\"", "\\\"")
  #   noticeCmd << "&&fastlane wx_message_notice wx_notice_token:#{Helper::YKWECHAT_ROBOT_TOKEN} msg_title:\"CI work failed\" notice_message:\"#{commandShell}\""
  #   puts "notice_command:#{noticeCmd}"
  #   system(noticeCmd)
  # end

  code
end

.executeFastlaneLane(lane_name, optionHash) ⇒ Object



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/actions/YKFastlaneExecute.rb', line 70

def self.executeFastlaneLane(lane_name, optionHash)
  dict = {}
  dict.update(optionHash)
  if optionHash[:wxwork_access_token].blank?
    wxtoken = YKCitool::Helper.load_config_value(YKCitool::Helper::K_wx_access_token)
    dict.update({:wxwork_access_token => wxtoken})
  end

  option_str = exchangOptionMapToStr(dict)
  command = "fastlane #{lane_name} #{option_str}" unless option_str.blank?

  command_pre = "export LANG=en_US.UTF-8 && export LANGUAGE=en_US.UTF-8 && export LC_ALL=en_US.UTF-8 && which ruby"
  command_pre << " && cd #{YKCitool::Helper.fastlane_script()}"

  executeCommand(command_pre, command, lane_name)
end