Class: Fastlane::Actions::ScpAction

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

Constant Summary

Constants inherited from Fastlane::Action

Fastlane::Action::AVAILABLE_CATEGORIES

Documentation collapse

Class Method Summary collapse

Methods inherited from Fastlane::Action

action_name, author, details, lane_context, method_missing, other_action, output, return_value, sample_return_value, sh, step_text

Class Method Details

.authorsObject



79
80
81
# File 'lib/fastlane/actions/scp.rb', line 79

def self.authors
  ["hjanuschka"]
end

.available_optionsObject



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
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/fastlane/actions/scp.rb', line 36

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

.categoryObject



108
109
110
# File 'lib/fastlane/actions/scp.rb', line 108

def self.category
  :misc
end

.descriptionObject



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

def self.description
  "Transfer files via SCP"
end

.example_codeObject



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/fastlane/actions/scp.rb', line 87

def self.example_code
  [
    'scp(
      host: "dev.januschka.com",
      username: "root",
      upload: {
        src: "/root/dir1",
        dst: "/tmp/new_dir"
      }
    )',
    'scp(
      host: "dev.januschka.com",
      username: "root",
      download: {
        src: "/root/dir1",
        dst: "/tmp/new_dir"
      }
    )'
  ]
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


83
84
85
# File 'lib/fastlane/actions/scp.rb', line 83

def self.is_supported?(platform)
  true
end

.run(params) ⇒ Object



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

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