Class: Fastlane::Actions::ArtifactoryAction

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

Constant Summary

Constants inherited from Fastlane::Action

Fastlane::Action::AVAILABLE_CATEGORIES

Class Method Summary collapse

Methods inherited from Fastlane::Action

action_name, authors, details, lane_context, method_missing, other_action, output, return_value, sample_return_value, sh, step_text

Class Method Details

.authorObject



46
47
48
# File 'lib/fastlane/actions/artifactory.rb', line 46

def self.author
  ["koglinjg"]
end

.available_optionsObject



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# File 'lib/fastlane/actions/artifactory.rb', line 67

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :file,
                                 env_name: "FL_ARTIFACTORY_FILE",
                                 description: "File to be uploaded to artifactory",
                                 optional: false),
    FastlaneCore::ConfigItem.new(key: :repo,
                                 env_name: "FL_ARTIFACTORY_REPO",
                                 description: "Artifactory repo to put the file in",
                                 optional: false),
    FastlaneCore::ConfigItem.new(key: :repo_path,
                                 env_name: "FL_ARTIFACTORY_REPO_PATH",
                                 description: "Path to deploy within the repo, including filename",
                                 optional: false),
    FastlaneCore::ConfigItem.new(key: :endpoint,
                                 env_name: "FL_ARTIFACTORY_ENDPOINT",
                                 description: "Artifactory endpoint",
                                 optional: false),
    FastlaneCore::ConfigItem.new(key: :username,
                                 env_name: "FL_ARTIFACTORY_USERNAME",
                                 description: "Artifactory username",
                                 optional: false),
    FastlaneCore::ConfigItem.new(key: :password,
                                 env_name: "FL_ARTIFACTORY_PASSWORD",
                                 description: "Artifactory password",
                                 optional: false),
    FastlaneCore::ConfigItem.new(key: :properties,
                                 env_name: "FL_ARTIFACTORY_PROPERTIES",
                                 description: "Artifact properties hash",
                                 is_string: false,
                                 default_value: {},
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :ssl_pem_file,
                                 env_name: "FL_ARTIFACTORY_SSL_PEM_FILE",
                                 description: "Location of pem file to use for ssl verification",
                                 default_value: nil,
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :ssl_verify,
                                 env_name: "FL_ARTIFACTORY_SSL_VERIFY",
                                 description: "Verify SSL",
                                 default_value: true,
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :proxy_username,
                                 env_name: "FL_ARTIFACTORY_PROXY_USERNAME",
                                 description: "Proxy username",
                                 default_value: nil,
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :proxy_password,
                                 env_name: "FL_ARTIFACTORY_PROXY_PASSWORD",
                                 description: "Proxy password",
                                 default_value: nil,
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :proxy_address,
                                 env_name: "FL_ARTIFACTORY_PROXY_ADDRESS",
                                 description: "Proxy address",
                                 default_value: nil,
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :proxy_port,
                                 env_name: "FL_ARTIFACTORY_PROXY_PORT",
                                 description: "Proxy port",
                                 default_value: nil,
                                 optional: true)
  ]
end

.categoryObject



63
64
65
# File 'lib/fastlane/actions/artifactory.rb', line 63

def self.category
  :misc
end

.connect_to_artifactory(params) ⇒ Object



30
31
32
33
34
35
36
# File 'lib/fastlane/actions/artifactory.rb', line 30

def self.connect_to_artifactory(params)
  config_keys = [:endpoint, :username, :password, :ssl_pem_file, :ssl_verify, :proxy_username, :proxy_password, :proxy_address, :proxy_port]
  config = params.values.select do |key|
    config_keys.include? key
  end
  Artifactory::Client.new(config)
end

.descriptionObject



38
39
40
# File 'lib/fastlane/actions/artifactory.rb', line 38

def self.description
  'This action uploads an artifact to artifactory'
end

.example_codeObject



50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/fastlane/actions/artifactory.rb', line 50

def self.example_code
  [
    'artifactory(
      username: "username",
      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
    )'
  ]
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/fastlane/actions/artifactory.rb', line 42

def self.is_supported?(platform)
  true
end

.run(params) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/fastlane/actions/artifactory.rb', line 4

def self.run(params)
  Actions.verify_gem!('artifactory')

  require 'artifactory'
  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
    artifact.checksums = {
        "sha1" => Digest::SHA1.file(file_path),
        "md5" => Digest::MD5.file(file_path)
    }
    UI.message("Uploading file: #{artifact.local_path} ...")
    upload = artifact.upload(params[:repo], params[:repo_path], params[:properties])
    UI.message("Uploaded Artifact:")
    UI.message("Repo: #{upload.repo}")
    UI.message("URI: #{upload.uri}")
    UI.message("Size: #{upload.size}")
    UI.message("SHA1: #{upload.sha1}")
  else
    UI.message("File not found: '#{file_path}'")
  end
end