fastlane/lib/fastlane/actions/artifactory.rb in fastlane-2.171.0 vs fastlane/lib/fastlane/actions/artifactory.rb in fastlane-2.172.0
- old
+ new
@@ -8,11 +8,16 @@
class ArtifactoryAction < Action
def self.run(params)
Actions.verify_gem!('artifactory')
require 'artifactory'
+
+ UI.user_error!("Cannot connect to Artifactory - 'username' was provided but it's missing 'password'") if params[:username] && !params[:password]
+ UI.user_error!("Cannot connect to Artifactory - 'password' was provided but it's missing 'username'") if !params[:username] && params[:password]
+ UI.user_error!("Cannot connect to Artifactory - either 'api_key', or 'username' and 'password' must be provided") if !params[:api_key] && !params[:username]
file_path = File.absolute_path(params[:file])
+
if File.exist?(file_path)
client = connect_to_artifactory(params)
artifact = Artifactory::Resource::Artifact.new
artifact.client = client
artifact.local_path = file_path
@@ -35,21 +40,25 @@
UI.message("File not found: '#{file_path}'")
end
end
def self.connect_to_artifactory(params)
- config_keys = [:endpoint, :username, :password, :ssl_pem_file, :ssl_verify, :proxy_username, :proxy_password, :proxy_address, :proxy_port, :read_timeout]
+ config_keys = [:endpoint, :username, :password, :api_key, :ssl_pem_file, :ssl_verify, :proxy_username, :proxy_password, :proxy_address, :proxy_port, :read_timeout]
config = params.values.select do |key|
config_keys.include?(key)
end
Artifactory::Client.new(config)
end
def self.description
'This action uploads an artifact to artifactory'
end
+ def self.details
+ 'Connect to the artifactory server using either a username/password or an api_key'
+ end
+
def self.is_supported?(platform)
true
end
def self.author
@@ -70,10 +79,17 @@
password: "password",
endpoint: "https://artifactory.example.com/artifactory/",
file: "example.ipa", # File to upload
repo: "mobile_artifacts", # Artifactory repo
repo_path: "/ios/appname/example-major.minor.ipa" # Path to place the artifact including its filename
+ )',
+ 'artifactory(
+ api_key: "api_key",
+ endpoint: "https://artifactory.example.com/artifactory/",
+ file: "example.ipa", # File to upload
+ repo: "mobile_artifacts", # Artifactory repo
+ repo_path: "/ios/appname/example-major.minor.ipa" # Path to place the artifact including its filename
)'
]
end
def self.category
@@ -99,15 +115,32 @@
description: "Artifactory endpoint",
optional: false),
FastlaneCore::ConfigItem.new(key: :username,
env_name: "FL_ARTIFACTORY_USERNAME",
description: "Artifactory username",
- optional: false),
+ optional: true,
+ conflicting_options: [:api_key],
+ conflict_block: proc do |value|
+ UI.user_error!("You can't use option '#{value.key}' along with 'username'")
+ end),
FastlaneCore::ConfigItem.new(key: :password,
env_name: "FL_ARTIFACTORY_PASSWORD",
description: "Artifactory password",
sensitive: true,
- optional: false),
+ optional: true,
+ conflicting_options: [:api_key],
+ conflict_block: proc do |value|
+ UI.user_error!("You can't use option '#{value.key}' along with 'password'")
+ end),
+ FastlaneCore::ConfigItem.new(key: :api_key,
+ env_name: "FL_ARTIFACTORY_API_KEY",
+ description: "Artifactory API key",
+ sensitive: true,
+ optional: true,
+ conflicting_options: [:username, :password],
+ conflict_block: proc do |value|
+ UI.user_error!("You can't use option '#{value.key}' along with 'api_key'")
+ end),
FastlaneCore::ConfigItem.new(key: :properties,
env_name: "FL_ARTIFACTORY_PROPERTIES",
description: "Artifact properties hash",
is_string: false,
default_value: {},