Class: Fastlane::Actions::UploadDsymToBuglyAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/upload_dsym_to_bugly/actions/upload_dsym_to_bugly_action.rb

Class Method Summary collapse

Class Method Details

.authorsObject



64
65
66
# File 'lib/fastlane/plugin/upload_dsym_to_bugly/actions/upload_dsym_to_bugly_action.rb', line 64

def self.authors
  ["liubo"]
end

.available_optionsObject



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
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
# File 'lib/fastlane/plugin/upload_dsym_to_bugly/actions/upload_dsym_to_bugly_action.rb', line 77

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :app_id,
                                 env_name: "FL_UPLOAD_DSYM_TO_BUGLY_APP_ID",
                                 description: "app id",
                                 is_string: true,
                                 verify_block: proc do |value|
                                   UI.user_error!("No APP id for UploadDsymToBuglyAction given, pass using `app_id: 'app_id'`") unless (value and not value.empty?)
                                 end),
    FastlaneCore::ConfigItem.new(key: :app_key,
                                 env_name: "FL_UPLOAD_DSYM_TO_BUGLY_APP_KEY",
                                 description: "app key",
                                 is_string: true,
                                 verify_block: proc do |value|
                                   UI.user_error!("No APP key for UploadDsymToBuglyAction given, pass using `api_key: 'app_key'`") unless (value and not value.empty?)
                                 end),
    FastlaneCore::ConfigItem.new(key: :bundle_id,
                                 env_name: "FL_UPLOAD_DSYM_TO_BUGLY_BUNDLE_ID",
                                 description: "bundle id",
                                 is_string: true,
                                 verify_block: proc do |value|
                                   UI.user_error!("No symbol type for UploadDsymToBuglyAction given, pass using `bundle_id: 'bundle_id'`") unless (value and not value.empty?)
                                 end),
    FastlaneCore::ConfigItem.new(key: :version,
                                 env_name: "FL_UPLOAD_DSYM_TO_BUGLY_VERSION",
                                 description: "app version",
                                 is_string: true,
                                 verify_block: proc do |value|
                                   UI.user_error!("No symbol type for UploadDsymToBuglyAction given, pass using `version: 'version'`") unless (value and not value.empty?)
                                 end),
    FastlaneCore::ConfigItem.new(key: :file_path,
                                 env_name: "FL_UPLOAD_DSYM_TO_BUGLY_FILE",
                                 description: "file path",
                                 is_string: true,
                                 verify_block: proc do |value|
                                   UI.user_error!("No symbol type for UploadDsymToBuglyAction given, pass using `file_path: 'file_path'`") unless (value and not value.empty?)
                                 end),
    FastlaneCore::ConfigItem.new(key: :platform,
                                 env_name: "FL_UPLOAD_DSYM_TO_BUGLY_FILE",
                                 description: "platform",
                                 is_string: true,
                                 default_value: "IOS",
                                 verify_block: proc do |value|
                                   UI.user_error!("platform value error, available values: IOS, Android") unless (value == "IOS" or value == "Android")
                                end),
    FastlaneCore::ConfigItem.new(key: :raise_if_error,
                                 env_name: "FL_UPLOAD_DSYM_TO_BUGLY_RAISE_IF_ERROR",
                                 description: "Raises an error if fails, so you can fail CI/CD jobs if necessary \(true/false)",
                                 default_value: true,
                                 is_string: false,
                                 type: Boolean,
                                 optional: false),
    FastlaneCore::ConfigItem.new(key: :java_path,
                                 env_name: "FL_UPLOAD_DSYM_TO_BUGLY_JAVA_PATH",
                                 description: "Use specific Java, instead of system one",
                                 default_value: nil,
                                 is_string: true,
                                 optional: true),
  ]
end

.descriptionObject



60
61
62
# File 'lib/fastlane/plugin/upload_dsym_to_bugly/actions/upload_dsym_to_bugly_action.rb', line 60

def self.description
  "upload_dsym_to_bugly"
end

.detailsObject



72
73
74
75
# File 'lib/fastlane/plugin/upload_dsym_to_bugly/actions/upload_dsym_to_bugly_action.rb', line 72

def self.details
  # Optional:
  ""
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


144
145
146
# File 'lib/fastlane/plugin/upload_dsym_to_bugly/actions/upload_dsym_to_bugly_action.rb', line 144

def self.is_supported?(platform)
  platform == :ios
end

.outputObject



138
139
140
141
142
# File 'lib/fastlane/plugin/upload_dsym_to_bugly/actions/upload_dsym_to_bugly_action.rb', line 138

def self.output
  [
    ["UPLOAD_DSYM_TO_BUGLY_RESULT", "upload result"],
  ]
end

.return_valueObject



68
69
70
# File 'lib/fastlane/plugin/upload_dsym_to_bugly/actions/upload_dsym_to_bugly_action.rb', line 68

def self.return_value
  # If your method provides a return value, you can describe here what it does
end

.run(params) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
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
50
51
52
53
54
55
56
57
58
# File 'lib/fastlane/plugin/upload_dsym_to_bugly/actions/upload_dsym_to_bugly_action.rb', line 11

def self.run(params)

  jar_path = File.expand_path('../../jars/buglyqq-upload-symbol.jar', __FILE__)
  UI.message "jar path: #{jar_path}"

  file_path = File.expand_path("#{params[:file_path]}")
  UI.message "file path: #{file_path}"

  unzip_path = File.expand_path(".upload_dsym_to_bugly_tmp", "#{File.dirname("#{file_path}")}") 
  UI.message "unzip path: #{unzip_path}"

  if Dir.exist?(unzip_path)
    FileUtils.rm_r(unzip_path, force: true)
  end

  if !Dir.glob(file_path).empty?
      sh("unzip -o \"#{file_path}\" -d \"#{unzip_path}\"")
  else
    UI.message "dSYM zip File don't exist"
    Actions.lane_context[SharedValues::UPLOAD_DSYM_TO_BUGLY_RESULT] = false
    raise if params[:raise_if_error]
  end

  java_path = params[:java_path] || 'java'
  cmd = "#{java_path} -jar \"#{jar_path}\" -appid \"#{params[:app_id]}\" -appkey \"#{params[:app_key]}\" -bundleid \"#{params[:bundle_id]}\" -version \"#{params[:version]}\" -platform \"#{params[:platform]}\" -inputSymbol \"#{unzip_path}\""

  log_file = "dSYM_upload_result.log"

  begin
    sh("#{cmd} > #{log_file}")
    log_content = File.read("#{log_file}")

    success = log_content.include?("retCode: 200") and log_content.include?("\"msg\":\"所有符号表都已经上传过。\"")
    if success
      UI.success " 🎉 🎉 🎉 dSYM upload successfully (づ。◕‿‿◕。)づ"            
      Actions.lane_context[SharedValues::UPLOAD_DSYM_TO_BUGLY_RESULT] = true
    else
      UI.error "┭┮﹏┭┮ dSYM upload failed ┭┮﹏┭┮"
      Actions.lane_context[SharedValues::UPLOAD_DSYM_TO_BUGLY_RESULT] = false
      raise if params[:raise_if_error]        
    end

  rescue => exception
    UI.message "dSYM upload failed, See log output above"
    Actions.lane_context[SharedValues::UPLOAD_DSYM_TO_BUGLY_RESULT] = false
    raise if params[:raise_if_error]
  end
end