fastlane/lib/fastlane/actions/nexus_upload.rb in fastlane-2.97.0 vs fastlane/lib/fastlane/actions/nexus_upload.rb in fastlane-2.98.0
- old
+ new
@@ -12,11 +12,27 @@
Fastlane::Actions.sh(command.join(' '), log: params[:verbose])
end
def self.upload_url(params)
- "#{params[:endpoint]}#{params[:mount_path]}/service/local/artifact/maven/content".shellescape
+ url = "#{params[:endpoint]}#{params[:mount_path]}"
+
+ if params[:nexus_version] == 2
+ url << "/service/local/artifact/maven/content"
+ else
+ file_extension = File.extname(params[:file]).shellescape
+
+ url << "/repository/#{params[:repo_id]}"
+ url << "/#{params[:repo_group_id].gsub('.', '/')}"
+ url << "/#{params[:repo_project_name]}"
+ url << "/#{params[:repo_project_version]}"
+ url << "/#{params[:repo_project_name]}-#{params[:repo_project_version]}"
+ url << "-#{params[:repo_classifier]}" if params[:repo_classifier]
+ url << file_extension.to_s
+ end
+
+ url.shellescape
end
def self.verbose(params)
params[:verbose] ? "--verbose" : "--silent"
end
@@ -24,23 +40,28 @@
def self.upload_options(params)
file_path = File.expand_path(params[:file]).shellescape
file_extension = file_path.split('.').last.shellescape
options = []
- options << "-F p=zip"
- options << "-F hasPom=false"
- options << "-F r=#{params[:repo_id].shellescape}"
- options << "-F g=#{params[:repo_group_id].shellescape}"
- options << "-F a=#{params[:repo_project_name].shellescape}"
- options << "-F v=#{params[:repo_project_version].shellescape}"
+ if params[:nexus_version] == 2
+ options << "-F p=zip"
+ options << "-F hasPom=false"
+ options << "-F r=#{params[:repo_id].shellescape}"
+ options << "-F g=#{params[:repo_group_id].shellescape}"
+ options << "-F a=#{params[:repo_project_name].shellescape}"
+ options << "-F v=#{params[:repo_project_version].shellescape}"
- if params[:repo_classifier]
- options << "-F c=#{params[:repo_classifier].shellescape}"
+ if params[:repo_classifier]
+ options << "-F c=#{params[:repo_classifier].shellescape}"
+ end
+
+ options << "-F e=#{file_extension}"
+ options << "-F file=@#{file_path}"
+ else
+ options << "--upload-file #{file_path}"
end
- options << "-F e=#{file_extension}"
- options << "-F file=@#{file_path}"
options << "-u #{params[:username].shellescape}:#{params[:password].shellescape}"
options
end
@@ -105,11 +126,11 @@
env_name: "FL_NEXUS_ENDPOINT",
description: "Nexus endpoint e.g. http://nexus:8081",
optional: false),
FastlaneCore::ConfigItem.new(key: :mount_path,
env_name: "FL_NEXUS_MOUNT_PATH",
- description: "Nexus mount path",
+ description: "Nexus mount path (Nexus 3 instances have this configured as empty by default)",
default_value: "/nexus",
optional: true),
FastlaneCore::ConfigItem.new(key: :username,
env_name: "FL_NEXUS_USERNAME",
description: "Nexus username",
@@ -122,10 +143,22 @@
env_name: "FL_NEXUS_SSL_VERIFY",
description: "Verify SSL",
is_string: false,
default_value: true,
optional: true),
+ FastlaneCore::ConfigItem.new(key: :nexus_version,
+ env_name: "FL_NEXUS_MAJOR_VERSION",
+ description: "Nexus major version",
+ type: Integer,
+ default_value: 2,
+ optional: true,
+ verify_block: proc do |value|
+ min_version = 2
+ max_version = 3
+ UI.user_error!("Unsupported version (#{value}) min. supported version: #{min_version}") unless value >= min_version
+ UI.user_error!("Unsupported version (#{value}) max. supported version: #{max_version}") unless value <= max_version
+ end),
FastlaneCore::ConfigItem.new(key: :verbose,
env_name: "FL_NEXUS_VERBOSE",
description: "Make detailed output",
is_string: false,
default_value: false,
@@ -149,19 +182,34 @@
optional: true)
]
end
def self.authors
- ["xfreebird"]
+ ["xfreebird", "mdio"]
end
def self.is_supported?(platform)
true
end
def self.example_code
[
- 'nexus_upload(
+ '# for Nexus 2
+ nexus_upload(
+ file: "/path/to/file.ipa",
+ repo_id: "artefacts",
+ repo_group_id: "com.fastlane",
+ repo_project_name: "ipa",
+ repo_project_version: "1.13",
+ repo_classifier: "dSYM", # Optional
+ endpoint: "http://localhost:8081",
+ username: "admin",
+ password: "admin123"
+ )',
+ '# for Nexus 3
+ nexus_upload(
+ nexus_version: 3,
+ mount_path: "",
file: "/path/to/file.ipa",
repo_id: "artefacts",
repo_group_id: "com.fastlane",
repo_project_name: "ipa",
repo_project_version: "1.13",