Class: Fastlane::Actions::RawUploadAction

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

Class Method Summary collapse

Class Method Details

.authorsObject



24
25
26
# File 'lib/fastlane/plugin/nexus_raw_upload/actions/raw_upload_action.rb', line 24

def self.authors
  ["Thang Nguyen Cao"]
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
# File 'lib/fastlane/plugin/nexus_raw_upload/actions/raw_upload_action.rb', line 37

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :file,
                                 description: "File to be uploaded to Nexus",
                                 optional: false,
                                 verify_block: proc do |value|
                                   file_path = File.expand_path(value)
                                   UI.user_error!("Couldn't find file at path '#{file_path}'") unless File.exist?(file_path)
                                 end),
    FastlaneCore::ConfigItem.new(key: :repository,
                                 description: "Nexus repository e.g. cdn-releases",
                                 optional: false),
    FastlaneCore::ConfigItem.new(key: :raw_directory,
                                 description: "Nexus raw directory e.g. artifacts",
                                 optional: false),
    FastlaneCore::ConfigItem.new(key: :file_name,
                                 description: "Nexus file name",
                                 optional: false),
    FastlaneCore::ConfigItem.new(key: :endpoint,
                                 description: "Nexus endpoint e.g. http://nexus:8081",
                                 optional: false),
    FastlaneCore::ConfigItem.new(key: :username,
                                 description: "Nexus username",
                                 optional: false),
    FastlaneCore::ConfigItem.new(key: :password,
                                 description: "Nexus password",
                                 optional: false),
    FastlaneCore::ConfigItem.new(key: :ssl_verify,
                                 description: "Verify SSL",
                                 type: Boolean,
                                 default_value: true,
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :verbose,
                                 description: "Make detailed output",
                                 type: Boolean,
                                 default_value: false,
                                 optional: true)
  ]
end

.descriptionObject



20
21
22
# File 'lib/fastlane/plugin/nexus_raw_upload/actions/raw_upload_action.rb', line 20

def self.description
  "Upload a raw asset to [Sonatype Nexus platform](https://www.sonatype.com)"
end

.detailsObject



32
33
34
35
# File 'lib/fastlane/plugin/nexus_raw_upload/actions/raw_upload_action.rb', line 32

def self.details
  # Optional:
  ""
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


77
78
79
80
81
82
83
# File 'lib/fastlane/plugin/nexus_raw_upload/actions/raw_upload_action.rb', line 77

def self.is_supported?(platform)
  # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
  # See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
  #
  # [:ios, :mac, :android].include?(platform)
  true
end

.return_valueObject



28
29
30
# File 'lib/fastlane/plugin/nexus_raw_upload/actions/raw_upload_action.rb', line 28

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

.run(params) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/fastlane/plugin/nexus_raw_upload/actions/raw_upload_action.rb', line 8

def self.run(params)
  command = []
  command << "curl"
  command << verbose(params)
  command << "--fail"
  command += ssl_options(params)
  command += upload_options(params)
  command << upload_url(params)

  Fastlane::Actions.sh(command.join(' '), log: params[:verbose])
end

.ssl_options(params) ⇒ Object



89
90
91
92
93
94
95
96
# File 'lib/fastlane/plugin/nexus_raw_upload/actions/raw_upload_action.rb', line 89

def self.ssl_options(params)
  options = []
  unless params[:ssl_verify]
    options << "--insecure"
  end

  options
end

.upload_options(params) ⇒ Object



98
99
100
101
102
103
104
105
106
# File 'lib/fastlane/plugin/nexus_raw_upload/actions/raw_upload_action.rb', line 98

def self.upload_options(params)
  file_path = File.expand_path(params[:file]).shellescape

  options = []
  options << "--upload-file #{file_path}"
  options << "-u #{params[:username].shellescape}:#{params[:password].shellescape}"

  options
end

.upload_url(params) ⇒ Object



108
109
110
111
112
113
114
115
116
117
# File 'lib/fastlane/plugin/nexus_raw_upload/actions/raw_upload_action.rb', line 108

def self.upload_url(params)
  file_extension = File.extname(params[:file]).shellescape

  url = (params[:endpoint]).to_s
  url << "/repository/#{params[:repository]}"
  url << "/#{params[:raw_directory]}"
  url << "/#{params[:file_name]}"
  url << file_extension.to_s
  url.shellescape
end

.verbose(params) ⇒ Object



85
86
87
# File 'lib/fastlane/plugin/nexus_raw_upload/actions/raw_upload_action.rb', line 85

def self.verbose(params)
  params[:verbose] ? "--verbose" : "--silent"
end