Class: Fastlane::Actions::GsExecuteCommandAction

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

Class Method Summary collapse

Class Method Details

.authorsObject



70
71
72
# File 'lib/fastlane/plugin/gs_deliver/actions/gs_execute_command.rb', line 70

def self.authors
  ["Сергей Веселовский"]
end

.available_optionsObject



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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# File 'lib/fastlane/plugin/gs_deliver/actions/gs_execute_command.rb', line 83

def self.available_options
  [
      FastlaneCore::ConfigItem.new(key: :cmd,
                           description: "Command that indicates bot action",
                              optional: true,
                                  type: String),
      FastlaneCore::ConfigItem.new(key: :buildNumber,
                                   description: "buildNumber",
                                   optional: true,
                                   type: Integer),
      FastlaneCore::ConfigItem.new(key: :project,
                                   description: "project",
                                   optional: true,
                                   type: String),
      FastlaneCore::ConfigItem.new(key: :testingProject,
                                   description: "testingProject",
                                   optional: true,
                                   type: String),
      FastlaneCore::ConfigItem.new(key: :displayVersionName,
                                   description: "displayVersionName",
                                   optional: true,
                                   type: String),
      FastlaneCore::ConfigItem.new(key: :forgeVersionName,
                                   description: "forgeVersionName",
                                   optional: true,
                                   type: String),
      FastlaneCore::ConfigItem.new(key: :nameReplacement,
                                   description: "nameReplacement",
                                   optional: true,
                                   type: String),
      FastlaneCore::ConfigItem.new(key: :namePrefix,
                                   description: "namePrefix",
                                   optional: true,
                                   type: String),
      FastlaneCore::ConfigItem.new(key: :namePostfix,
                                   description: "namePostfix",
                                   optional: true,
                                   type: String),
      FastlaneCore::ConfigItem.new(key: :messageHeader,
                                   description: "messageHeader",
                                   optional: true,
                                   type: String),
      FastlaneCore::ConfigItem.new(key: :storeIdentificator,
                                   description: "storeIdentificator",
                                   optional: true,
                                   type: String),
      FastlaneCore::ConfigItem.new(key: :platform,
                                   description: "platform",
                                   optional: true,
                                   type: String),
      FastlaneCore::ConfigItem.new(key: :rc,
                                   description: "rc",
                                   optional: true,
                                   is_string:false),
      FastlaneCore::ConfigItem.new(key: :callCmd,
                                   description: "callCmd",
                                   optional: true,
                                   is_string: false),
      FastlaneCore::ConfigItem.new(key: :storeVersion,
                                   description: "storeVersion",
                                   optional: true,
                                   type: String),
      FastlaneCore::ConfigItem.new(key: :request,
                                   description: "request",
                                   optional: true,
                                   type: String),
      FastlaneCore::ConfigItem.new(key: :alias,
                                   description: "alias",
                                   optional: true,
                                   type: String)
  ]
end

.descriptionObject



66
67
68
# File 'lib/fastlane/plugin/gs_deliver/actions/gs_execute_command.rb', line 66

def self.description
  "Gradoservice plugin to rule apps releases"
end

.detailsObject



78
79
80
81
# File 'lib/fastlane/plugin/gs_deliver/actions/gs_execute_command.rb', line 78

def self.details
  # Optional:
  "Gradoservice plugin to rule apps releases for our scheme"
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


156
157
158
159
160
161
162
# File 'lib/fastlane/plugin/gs_deliver/actions/gs_execute_command.rb', line 156

def self.is_supported?(platform)
  # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
  # See: https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Platforms.md
  #
  # [:ios, :mac, :android].include?(platform)
  true
end

.return_valueObject



74
75
76
# File 'lib/fastlane/plugin/gs_deliver/actions/gs_execute_command.rb', line 74

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

.run(options) ⇒ Object



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
59
60
61
62
63
64
# File 'lib/fastlane/plugin/gs_deliver/actions/gs_execute_command.rb', line 22

def self.run(options)
  require 'json'
  if options[:request] == nil
    raise "Can't send command to server. :request is required field"
  end

  if options[:callCmd] != nil && options[:callCmd].class == Hash
    if options[:storeIdentificator] == nil || options[:storeVersion] == nil || options[:platform] == nil || options[:rc] == nil || options[:callCmd] == nil
      raise "Can't send command to server. :storeIdentificator, :storeVersion, :platform, :rc, :callCmd are required fields"
    end
    command = options[:callCmd]
    if command[:alias] == nil || command[:displayVersionName] == nil || command[:cmd] == nil
      raise "Can't send command to server. :project, :displayVersionName, :cmd are required fields"
    end
  else
    if options[:alias] == nil || options[:displayVersionName] == nil || options[:cmd] == nil
      raise "Can't send command to server. :project, :displayVersionName, :cmd are required fields"
    end
  end



  params = {}
  options.all_keys.each do |key|
    params[key] = options[key] if options[key] != nil && key != :request
  end
  UI.message(params.to_s)
  json_params = params.to_json

  client = Spaceship::GSBotClient.new
  url = options[:request]
  response = client.request(:post) do |req|
    req.url url
    req.body = json_params
    req.headers['Content-Type'] = 'application/json'
  end

  if response.success?
    return response
  else
    raise (client.class.hostname + url + ' ' + response.status.to_s + ' ' + response.body['message'])
  end
end