Class: Fastlane::Actions::ScpAction

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

Constant Summary

Constants inherited from Fastlane::Action

Fastlane::Action::AVAILABLE_CATEGORIES, Fastlane::Action::RETURN_TYPES

Documentation collapse

Class Method Summary collapse

Methods inherited from Fastlane::Action

action_name, author, deprecated_notes, details, lane_context, method_missing, other_action, output, return_type, return_value, sample_return_value, shell_out_should_use_bundle_exec?, step_text

Class Method Details

.authorsObject



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

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
78
# File 'fastlane/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",
                                 sensitive: true,
                                 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



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

def self.category
  :misc
end

.descriptionObject



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

def self.description
  "Transfer files via SCP"
end

.example_codeObject



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

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:



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

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 'fastlane/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[:download][:src], params[:download][:dst]].join(': '))
      unless params[:download][:dst]
        ret = t_ret
      end
    end
  end
  ret
end