Class: Fastlane::Actions::ScpAction

Inherits:
Fastlane::Action show all
Defined in:
lib/fastlane/actions/scp.rb

Documentation collapse

Class Method Summary collapse

Methods inherited from Fastlane::Action

action_name, author, details, output, return_value, sh, step_text

Class Method Details

.authorsObject



86
87
88
# File 'lib/fastlane/actions/scp.rb', line 86

def self.authors
  ["hjanuschka"]
end

.available_optionsObject



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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/fastlane/actions/scp.rb', line 37

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :username,
                                 short_option: "-u",
                                 env_name: "FL_SSH_USERNAME",
                                 description: "Username",
                                 is_string: true
                                ),
    FastlaneCore::ConfigItem.new(key: :password,
                                 short_option: "-p",
                                 env_name: "FL_SSH_PASSWORD",
                                 description: "Password",
                                 optional: true,
                                 is_string: true
                                ),
    FastlaneCore::ConfigItem.new(key: :host,
                                 short_option: "-H",
                                 env_name: "FL_SSH_HOST",
                                 description: "Hostname",
                                 is_string: true
                                ),
    FastlaneCore::ConfigItem.new(key: :port,
                                 short_option: "-P",
                                 env_name: "FL_SSH_PORT",
                                 description: "Port",
                                 optional: true,
                                 default_value: "22",
                                 is_string: true
                                ),
    FastlaneCore::ConfigItem.new(key: :upload,
                                 short_option: "-U",
                                 env_name: "FL_SCP_UPLOAD",
                                 description: "Upload",
                                 optional: true,
                                 is_string: false,
                                 type: Hash
                                ),
    FastlaneCore::ConfigItem.new(key: :download,
                                 short_option: "-D",
                                 env_name: "FL_SCP_DOWNLOAD",
                                 description: "Download",
                                 optional: true,
                                 is_string: false,
                                 type: Hash
                                )

  ]
end

.descriptionObject



33
34
35
# File 'lib/fastlane/actions/scp.rb', line 33

def self.description
  "Transfer files via SCP"
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


90
91
92
# File 'lib/fastlane/actions/scp.rb', line 90

def self.is_supported?(platform)
  true
end

.run(params) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/fastlane/actions/scp.rb', line 8

def self.run(params)
  Actions.verify_gem!('net-scp')
  require "net/scp"
  ret = nil
  Net::SCP.start(params[:host], params[:username], {port: params[:port].to_i, password: params[:password]}) do |scp|
    if params[:upload]
      scp.upload! params[:upload][:src], params[:upload][:dst], recursive: true
      UI.message(['[SCP COMMAND]', "Successfully Uploaded", params[:upload][:src], params[:upload][:dst]].join(': '))
    end
    if params[:download]

      t_ret = scp.download! params[:download][:src], params[:download][:dst], recursive: true
      UI.message(['[SCP COMMAND]', "Successfully Downloaded", params[:upload][:src], params[:upload][:dst]].join(': '))
      unless params[:download][:dst]
        ret = t_ret
      end
    end
  end
  ret
end