fastlane/lib/fastlane/actions/testfairy.rb in fastlane-2.89.0.beta.20180328050040 vs fastlane/lib/fastlane/actions/testfairy.rb in fastlane-2.89.0.beta.20180329050050

- old
+ new

@@ -3,15 +3,17 @@ module SharedValues TESTFAIRY_BUILD_URL = :TESTFAIRY_BUILD_URL end class TestfairyAction < Action - def self.upload_build(ipa, options) + def self.upload_build(upload_url, ipa, options) require 'faraday' require 'faraday_middleware' - connection = Faraday.new(url: "https://upload.testfairy.com") do |builder| + UI.success("Uploading to #{upload_url}...") + + connection = Faraday.new(url: upload_url) do |builder| builder.request(:multipart) builder.request(:url_encoded) builder.request(:retry, max: 3, interval: 5) builder.response(:json, content_type: /\bjson$/) builder.use(FaradayMiddleware::FollowRedirects) @@ -62,11 +64,14 @@ UI.user_error!("Unknown option: #{option}") end end end - client_options = Hash[params.values.map do |key, value| + # Rejecting key `upload_url` as we don't need it in options + client_options = Hash[params.values.reject do |key, value| + key == :upload_url + end.map do |key, value| case key when :api_key [key, value] when :ipa [key, value] @@ -89,11 +94,11 @@ end end] return params[:ipa] if Helper.test? - response = self.upload_build(params[:ipa], client_options) + response = self.upload_build(params[:upload_url], params[:ipa], client_options) if parse_response(response) UI.success("Build URL: #{Actions.lane_context[SharedValues::TESTFAIRY_BUILD_URL]}") UI.success("Build successfully uploaded to TestFairy.") else UI.user_error!("Error when trying to upload ipa to TestFairy") @@ -153,9 +158,15 @@ default_value: Actions.lane_context[SharedValues::DSYM_OUTPUT_PATH], default_value_dynamic: true, verify_block: proc do |value| UI.user_error!("Couldn't find dSYM file at path '#{value}'") unless File.exist?(value) end), + FastlaneCore::ConfigItem.new(key: :upload_url, + env_name: "FL_TESTFAIRY_UPLOAD_URL", # The name of the environment variable + description: "API URL for TestFairy", # a short description of this parameter + default_value: "https://upload.testfairy.com", + is_string: true, + optional: true), FastlaneCore::ConfigItem.new(key: :testers_groups, optional: true, type: Array, short_option: '-g', env_name: "FL_TESTFAIRY_TESTERS_GROUPS",