Class: Fastlane::Actions::ArtifactoryAction

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

Constant Summary

Constants inherited from Fastlane::Action

Fastlane::Action::AVAILABLE_CATEGORIES, Fastlane::Action::RETURN_TYPES

Class Method Summary collapse

Methods inherited from Fastlane::Action

action_name, authors, deprecated_notes, details, lane_context, method_missing, other_action, return_type, return_value, sample_return_value, shell_out_should_use_bundle_exec?, step_text

Class Method Details

.authorObject



55
56
57
# File 'fastlane/lib/fastlane/actions/artifactory.rb', line 55

def self.author
  ["koglinjg", "tommeier"]
end

.available_optionsObject



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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# File 'fastlane/lib/fastlane/actions/artifactory.rb', line 83

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",
                                 sensitive: true,
                                 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",
                                 is_string: false,
                                 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",
                                 sensitive: true,
                                 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),
    FastlaneCore::ConfigItem.new(key: :read_timeout,
                                 env_name: "FL_ARTIFACTORY_READ_TIMEOUT",
                                 description: "Read timeout",
                                 default_value: nil,
                                 optional: true)
  ]
end

.categoryObject



79
80
81
# File 'fastlane/lib/fastlane/actions/artifactory.rb', line 79

def self.category
  :misc
end

.connect_to_artifactory(params) ⇒ Object



39
40
41
42
43
44
45
# File 'fastlane/lib/fastlane/actions/artifactory.rb', line 39

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 = params.values.select do |key|
    config_keys.include?(key)
  end
  Artifactory::Client.new(config)
end

.descriptionObject



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

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

.example_codeObject



66
67
68
69
70
71
72
73
74
75
76
77
# File 'fastlane/lib/fastlane/actions/artifactory.rb', line 66

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:



51
52
53
# File 'fastlane/lib/fastlane/actions/artifactory.rb', line 51

def self.is_supported?(platform)
  true
end

.outputObject



59
60
61
62
63
64
# File 'fastlane/lib/fastlane/actions/artifactory.rb', line 59

def self.output
  [
    ['ARTIFACTORY_DOWNLOAD_URL', 'The download url for file uploaded'],
    ['ARTIFACTORY_DOWNLOAD_SIZE', 'The reported file size for file uploaded']
  ]
end

.run(params) ⇒ Object



9
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
# File 'fastlane/lib/fastlane/actions/artifactory.rb', line 9

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])

    Actions.lane_context[SharedValues::ARTIFACTORY_DOWNLOAD_URL] = upload.uri
    Actions.lane_context[SharedValues::ARTIFACTORY_DOWNLOAD_SIZE] = upload.size

    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