fastlane-plugin-sftp 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/fastlane/plugin/sftp/actions/sftp_download.rb +0 -0
- data/lib/fastlane/plugin/sftp/actions/sftp_upload.rb +0 -0
- data/lib/fastlane/plugin/sftp/helper/downloader.rb +4 -3
- data/lib/fastlane/plugin/sftp/helper/options.rb +85 -58
- data/lib/fastlane/plugin/sftp/helper/sftp_helper.rb +35 -14
- data/lib/fastlane/plugin/sftp/helper/uploader.rb +5 -5
- data/lib/fastlane/plugin/sftp/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ac51bdf322cdc7fd294125577506123707da8e7b
|
4
|
+
data.tar.gz: 4a15b34323794f3d2471d7cfec0fd1ae8b8ff04c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06a5384854ea56c9fa2ae0164d3eda938bb85967122ade3f3588deb672c5034cd19c42d34d3b8270de0b1fda81f838438193d331e8e76e3bf584580961692289
|
7
|
+
data.tar.gz: bce48cc6866ce9e166bd4c7e488280c0a03b75d04c604c76a5c29bb2cc53cc8853b3fc1720fdf970f0b0a61bb5a0ad5231f6f654ff2947b3a1112cf4c62db0c9
|
File without changes
|
File without changes
|
@@ -17,6 +17,7 @@ module Fastlane
|
|
17
17
|
#
|
18
18
|
|
19
19
|
attr_accessor :host
|
20
|
+
attr_accessor :port
|
20
21
|
attr_accessor :user
|
21
22
|
attr_accessor :password
|
22
23
|
attr_accessor :rsa_keypath
|
@@ -28,6 +29,7 @@ module Fastlane
|
|
28
29
|
def initialize(options)
|
29
30
|
self.options = options unless options.nil?
|
30
31
|
self.host = options[:server_url]
|
32
|
+
self.port = options[:server_port]
|
31
33
|
self.user = options[:server_user]
|
32
34
|
self.password = options[:server_password]
|
33
35
|
self.rsa_keypath = options[:server_key]
|
@@ -43,12 +45,11 @@ module Fastlane
|
|
43
45
|
def download
|
44
46
|
# Login & Download all files using RSA key or username/password
|
45
47
|
UI.message('download...')
|
46
|
-
session = Helper::SftpHelper.login(host, user, password, rsa_keypath, rsa_keypath_passphrase)
|
48
|
+
session = Helper::SftpHelper.login(host, port, user, password, rsa_keypath, rsa_keypath_passphrase)
|
47
49
|
UI.message('Downloading files...')
|
48
50
|
|
49
51
|
session.sftp.connect do |sftp|
|
50
|
-
|
51
|
-
downloads = sftp_download(sftp, source_files, target_dir)
|
52
|
+
downloads = sftp_download(sftp, files, target_dir)
|
52
53
|
downloads.each(&:wait)
|
53
54
|
|
54
55
|
# Lists the entries in a directory for verification
|
@@ -6,59 +6,82 @@ module Fastlane
|
|
6
6
|
class Options
|
7
7
|
def self.general_options
|
8
8
|
return [
|
9
|
-
FastlaneCore::ConfigItem.new(
|
10
|
-
|
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
|
-
|
9
|
+
FastlaneCore::ConfigItem.new(
|
10
|
+
key: :server_url,
|
11
|
+
short_option: '-r',
|
12
|
+
optional: false,
|
13
|
+
env_name: 'SERVER_URL',
|
14
|
+
description: 'URL of your server'
|
15
|
+
),
|
16
|
+
FastlaneCore::ConfigItem.new(
|
17
|
+
key: :server_port,
|
18
|
+
short_option: '-t',
|
19
|
+
optional: true,
|
20
|
+
env_name: 'SERVER_PORT',
|
21
|
+
type: Integer,
|
22
|
+
description: 'PORT used to connect to the server. Defaults to 22',
|
23
|
+
default_value: 22
|
24
|
+
),
|
25
|
+
FastlaneCore::ConfigItem.new(
|
26
|
+
key: :server_user,
|
27
|
+
short_option: '-u',
|
28
|
+
optional: false,
|
29
|
+
env_name: 'SERVER_USER',
|
30
|
+
description: 'USER of your server'
|
31
|
+
),
|
32
|
+
FastlaneCore::ConfigItem.new(
|
33
|
+
key: :server_password,
|
34
|
+
short_option: '-p',
|
35
|
+
optional: true,
|
36
|
+
env_name: 'SERVER_PASSWORD',
|
37
|
+
description: 'PASSWORD for your server (not for production)',
|
38
|
+
conflicting_options: [:server_key],
|
39
|
+
conflict_block: proc do |value|
|
40
|
+
UI.user_error!("You can't use 'server_password' and '#{value.key}' options in one run.")
|
41
|
+
end
|
42
|
+
),
|
43
|
+
FastlaneCore::ConfigItem.new(
|
44
|
+
key: :server_key,
|
45
|
+
short_option: '-k',
|
46
|
+
optional: true,
|
47
|
+
env_name: 'SERVER_KEY',
|
48
|
+
description: 'RSA key for your server',
|
49
|
+
conflicting_options: [:server_password],
|
50
|
+
conflict_block: proc do |value|
|
51
|
+
UI.user_error!("You can't use 'server_key' and '#{value.key}' options in one run.")
|
52
|
+
end,
|
53
|
+
verify_block: proc do |value|
|
54
|
+
UI.user_error!("Key file '#{value}' does not exist") unless File.exist?(value)
|
55
|
+
end
|
56
|
+
),
|
57
|
+
FastlaneCore::ConfigItem.new(
|
58
|
+
key: :server_key_passphrase,
|
59
|
+
short_option: '-v',
|
60
|
+
optional: true,
|
61
|
+
env_name: 'SERVER_KEY_PASSPHRASE',
|
62
|
+
description: 'Optional passphrase for the RSA key for your server. If required but not provided, user will be asked for'
|
63
|
+
)
|
45
64
|
]
|
46
65
|
end
|
47
66
|
|
48
67
|
def self.available_options_upload
|
49
68
|
return [].concat(general_options).concat(
|
50
69
|
[
|
51
|
-
FastlaneCore::ConfigItem.new(
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
70
|
+
FastlaneCore::ConfigItem.new(
|
71
|
+
key: :target_dir,
|
72
|
+
short_option: '-x',
|
73
|
+
description: 'target path on the server'
|
74
|
+
),
|
75
|
+
FastlaneCore::ConfigItem.new(
|
76
|
+
key: :file_paths,
|
77
|
+
short_option: '-j',
|
78
|
+
description: 'List of files/folders to upload',
|
79
|
+
type: Array,
|
80
|
+
verify_block: proc do |value|
|
81
|
+
UI.user_error!("you must provide at least one file to upload") if value.empty?
|
82
|
+
value.each { |entry| UI.user_error!("file '#{entry}' does not exist") unless File.exist?(entry) }
|
83
|
+
end
|
84
|
+
)
|
62
85
|
]
|
63
86
|
)
|
64
87
|
end
|
@@ -66,17 +89,21 @@ module Fastlane
|
|
66
89
|
def self.available_options_download
|
67
90
|
return [].concat(general_options).concat(
|
68
91
|
[
|
69
|
-
FastlaneCore::ConfigItem.new(
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
92
|
+
FastlaneCore::ConfigItem.new(
|
93
|
+
key: :target_dir,
|
94
|
+
short_option: '-x',
|
95
|
+
optional: true,
|
96
|
+
description: 'local target path to a folder where all downloaded files should be put'
|
97
|
+
),
|
98
|
+
FastlaneCore::ConfigItem.new(
|
99
|
+
key: :file_paths,
|
100
|
+
short_option: '-j',
|
101
|
+
description: 'List of remote files/folders to download',
|
102
|
+
type: Array,
|
103
|
+
verify_block: proc do |value|
|
104
|
+
UI.user_error!("you must provide at least one file to download") if value.empty?
|
105
|
+
end
|
106
|
+
)
|
80
107
|
]
|
81
108
|
)
|
82
109
|
end
|
@@ -11,7 +11,7 @@ module Fastlane
|
|
11
11
|
# as `Helper::SftpHelper.your_method`
|
12
12
|
#
|
13
13
|
|
14
|
-
def self.login(host, user, password, rsa_keypath, rsa_keypath_passphrase)
|
14
|
+
def self.login(host, port, user, password, rsa_keypath, rsa_keypath_passphrase)
|
15
15
|
if host.nil? || user.nil? || (password.nil? && rsa_keypath.nil?)
|
16
16
|
UI.user_error!('server_url, server_user and server_password or server_key must be set')
|
17
17
|
end
|
@@ -29,6 +29,10 @@ module Fastlane
|
|
29
29
|
verbose: logging_level,
|
30
30
|
non_interactive: true
|
31
31
|
}
|
32
|
+
unless port.nil?
|
33
|
+
UI.message("Using custom port #{port}...")
|
34
|
+
options[:port] = port
|
35
|
+
end
|
32
36
|
if !rsa_key.nil?
|
33
37
|
UI.message('Logging in with RSA key...')
|
34
38
|
options = options.merge({
|
@@ -65,13 +69,38 @@ module Fastlane
|
|
65
69
|
end
|
66
70
|
|
67
71
|
def self.remote_mkdir(sftp, remote_path)
|
68
|
-
sftp
|
72
|
+
return if remote_dir_exists?(sftp, remote_path)
|
73
|
+
|
74
|
+
path_parts = Pathname(remote_path).each_filename.to_a
|
75
|
+
UI.message("Pathparts = #{path_parts}")
|
76
|
+
path_value = remote_path.start_with?("/") ? "" : "."
|
77
|
+
path_parts.each do |path|
|
78
|
+
begin
|
79
|
+
path_value = path_value + File::SEPARATOR + path
|
80
|
+
UI.message("creating #{path_value}")
|
81
|
+
sftp.mkdir!(path_value)
|
82
|
+
rescue Net::SFTP::StatusException => e
|
83
|
+
# ignoring all errors while creating sub paths
|
84
|
+
UI.message("operation failed: #{e.message}")
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
# check for existence again
|
89
|
+
folder_exists = remote_dir_exists?(sftp, remote_path)
|
90
|
+
UI.user_error!("remote folder #{remote_path} does not exist and could not be created") unless folder_exists
|
91
|
+
end
|
92
|
+
|
93
|
+
def self.remote_dir_exists?(sftp, remote_path)
|
94
|
+
UI.message("Checking remote directory #{remote_path}")
|
95
|
+
attrs = sftp.stat!(remote_path)
|
96
|
+
UI.user_error!("Path #{remote_path} is not a directory") unless attrs.directory?
|
97
|
+
return true
|
69
98
|
rescue Net::SFTP::StatusException => e
|
70
|
-
#
|
71
|
-
# we handle code FX_FILE_ALREADY_EXISTS and FX_FAILURE the same
|
99
|
+
# directory does not exist, we have to create it
|
72
100
|
codes = Net::SFTP::Constants::StatusCodes
|
73
|
-
raise if e.code != codes::
|
74
|
-
UI.message("Remote
|
101
|
+
raise if e.code != codes::FX_NO_SUCH_FILE && e.code != codes::FX_NO_SUCH_PATH
|
102
|
+
UI.message("Remote directory #{remote_path} does not exist")
|
103
|
+
return false
|
75
104
|
end
|
76
105
|
|
77
106
|
def self.load_rsa_key(rsa_keypath)
|
@@ -85,14 +114,6 @@ module Fastlane
|
|
85
114
|
end
|
86
115
|
return rsa_key
|
87
116
|
end
|
88
|
-
|
89
|
-
def self.generate_remote_path(user, target_dir)
|
90
|
-
path = File.join('/', user, target_dir)
|
91
|
-
if user != "root"
|
92
|
-
path = File.join('/home', path)
|
93
|
-
end
|
94
|
-
return path
|
95
|
-
end
|
96
117
|
end
|
97
118
|
end
|
98
119
|
end
|
@@ -17,6 +17,7 @@ module Fastlane
|
|
17
17
|
#
|
18
18
|
|
19
19
|
attr_accessor :host
|
20
|
+
attr_accessor :port
|
20
21
|
attr_accessor :user
|
21
22
|
attr_accessor :password
|
22
23
|
attr_accessor :rsa_keypath
|
@@ -28,6 +29,7 @@ module Fastlane
|
|
28
29
|
def initialize(options)
|
29
30
|
self.options = options unless options.nil?
|
30
31
|
self.host = options[:server_url]
|
32
|
+
self.port = options[:server_port]
|
31
33
|
self.user = options[:server_user]
|
32
34
|
self.password = options[:server_password]
|
33
35
|
self.rsa_keypath = options[:server_key]
|
@@ -44,13 +46,11 @@ module Fastlane
|
|
44
46
|
# Login & Upload all files using RSA key or username/password
|
45
47
|
UI.message('upload...')
|
46
48
|
|
47
|
-
session = Helper::SftpHelper.login(host, user, password, rsa_keypath, rsa_keypath_passphrase)
|
49
|
+
session = Helper::SftpHelper.login(host, port, user, password, rsa_keypath, rsa_keypath_passphrase)
|
48
50
|
UI.message('Uploading files...')
|
49
51
|
|
50
52
|
session.sftp.connect do |sftp|
|
51
|
-
Helper::SftpHelper.remote_mkdir(sftp,
|
52
|
-
path = target_dir
|
53
|
-
|
53
|
+
Helper::SftpHelper.remote_mkdir(sftp, target_dir)
|
54
54
|
uploads = []
|
55
55
|
files.each do |file|
|
56
56
|
next unless Helper::SftpHelper.check_file(file)
|
@@ -64,7 +64,7 @@ module Fastlane
|
|
64
64
|
uploads.each(&:wait)
|
65
65
|
|
66
66
|
# Lists the entries in a directory for verification
|
67
|
-
sftp.dir.foreach(
|
67
|
+
sftp.dir.foreach(target_dir) do |entry|
|
68
68
|
UI.message(entry.longname)
|
69
69
|
end
|
70
70
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fastlane-plugin-sftp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oliver Limberg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-04-
|
11
|
+
date: 2019-04-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: net-ssh
|