dpl 1.8.48.travis.2486.5 → 1.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +2 -0
- data/.travis.yml +42 -21
- data/Gemfile +3 -98
- data/README.md +5 -16
- data/Rakefile +160 -1
- data/dpl-anynines.gemspec +3 -0
- data/dpl-atlas.gemspec +3 -0
- data/dpl-azure_webapps.gemspec +3 -0
- data/dpl-bintray.gemspec +3 -0
- data/dpl-bitballoon.gemspec +3 -0
- data/dpl-bluemix_cloud_foundry.gemspec +3 -0
- data/dpl-boxfuse.gemspec +3 -0
- data/dpl-catalyze.gemspec +3 -0
- data/dpl-chef_supermarket.gemspec +8 -0
- data/dpl-cloud66.gemspec +3 -0
- data/dpl-cloud_files.gemspec +3 -0
- data/dpl-cloud_foundry.gemspec +3 -0
- data/dpl-code_deploy.gemspec +3 -0
- data/dpl-deis.gemspec +3 -0
- data/dpl-divshot.gemspec +3 -0
- data/dpl-elastic_beanstalk.gemspec +3 -0
- data/dpl-engine_yard.gemspec +3 -0
- data/dpl-firebase.gemspec +3 -0
- data/dpl-gae.gemspec +3 -0
- data/dpl-gcs.gemspec +3 -0
- data/dpl-hackage.gemspec +3 -0
- data/dpl-heroku.gemspec +3 -0
- data/dpl-lambda.gemspec +3 -0
- data/dpl-launchpad.gemspec +3 -0
- data/dpl-modulus.gemspec +3 -0
- data/dpl-npm.gemspec +3 -0
- data/dpl-openshift.gemspec +3 -0
- data/dpl-ops_works.gemspec +3 -0
- data/dpl-packagecloud.gemspec +3 -0
- data/dpl-pages.gemspec +3 -0
- data/dpl-puppet_forge.gemspec +3 -0
- data/dpl-pypi.gemspec +3 -0
- data/dpl-releases.gemspec +3 -0
- data/dpl-rubygems.gemspec +3 -0
- data/dpl-s3.gemspec +3 -0
- data/dpl-scalingo.gemspec +3 -0
- data/dpl-script.gemspec +3 -0
- data/dpl-surge.gemspec +3 -0
- data/dpl-testfairy.gemspec +3 -0
- data/dpl-transifex.gemspec +3 -0
- data/dpl.gemspec +2 -31
- data/gemspec_helper.rb +49 -0
- data/lib/dpl/provider.rb +101 -58
- data/lib/dpl/version.rb +1 -1
- data/spec/provider_spec.rb +15 -34
- metadata +76 -107
- data/lib/dpl/provider/anynines.rb +0 -13
- data/lib/dpl/provider/appfog.rb +0 -21
- data/lib/dpl/provider/atlas.rb +0 -108
- data/lib/dpl/provider/azure_webapps.rb +0 -48
- data/lib/dpl/provider/bintray.rb +0 -509
- data/lib/dpl/provider/bitballoon.rb +0 -22
- data/lib/dpl/provider/bluemix_cloud_foundry.rb +0 -23
- data/lib/dpl/provider/boxfuse.rb +0 -57
- data/lib/dpl/provider/catalyze.rb +0 -49
- data/lib/dpl/provider/chef_supermarket.rb +0 -85
- data/lib/dpl/provider/cloud66.rb +0 -38
- data/lib/dpl/provider/cloud_files.rb +0 -38
- data/lib/dpl/provider/cloud_foundry.rb +0 -43
- data/lib/dpl/provider/code_deploy.rb +0 -154
- data/lib/dpl/provider/deis.rb +0 -128
- data/lib/dpl/provider/divshot.rb +0 -23
- data/lib/dpl/provider/elastic_beanstalk.rb +0 -195
- data/lib/dpl/provider/engine_yard.rb +0 -90
- data/lib/dpl/provider/firebase.rb +0 -27
- data/lib/dpl/provider/gae.rb +0 -97
- data/lib/dpl/provider/gcs.rb +0 -59
- data/lib/dpl/provider/hackage.rb +0 -29
- data/lib/dpl/provider/heroku.rb +0 -18
- data/lib/dpl/provider/heroku/api.rb +0 -98
- data/lib/dpl/provider/heroku/generic.rb +0 -94
- data/lib/dpl/provider/heroku/git.rb +0 -28
- data/lib/dpl/provider/lambda.rb +0 -236
- data/lib/dpl/provider/launchpad.rb +0 -48
- data/lib/dpl/provider/modulus.rb +0 -23
- data/lib/dpl/provider/npm.rb +0 -64
- data/lib/dpl/provider/openshift.rb +0 -59
- data/lib/dpl/provider/ops_works.rb +0 -132
- data/lib/dpl/provider/packagecloud.rb +0 -144
- data/lib/dpl/provider/pages.rb +0 -212
- data/lib/dpl/provider/puppet_forge.rb +0 -43
- data/lib/dpl/provider/pypi.rb +0 -103
- data/lib/dpl/provider/releases.rb +0 -139
- data/lib/dpl/provider/rubygems.rb +0 -51
- data/lib/dpl/provider/s3.rb +0 -123
- data/lib/dpl/provider/scalingo.rb +0 -97
- data/lib/dpl/provider/script.rb +0 -29
- data/lib/dpl/provider/surge.rb +0 -33
- data/lib/dpl/provider/testfairy.rb +0 -111
- data/lib/dpl/provider/transifex.rb +0 -45
- data/spec/provider/anynines_spec.rb +0 -20
- data/spec/provider/appfog_spec.rb +0 -35
- data/spec/provider/atlas_spec.rb +0 -99
- data/spec/provider/azure_webapps_spec.rb +0 -95
- data/spec/provider/bintray_spec.rb +0 -259
- data/spec/provider/bitballoon_spec.rb +0 -32
- data/spec/provider/bluemixcloudfoundry_spec.rb +0 -23
- data/spec/provider/boxfuse_spec.rb +0 -16
- data/spec/provider/catalyze_spec.rb +0 -39
- data/spec/provider/chef_supermarket_spec.rb +0 -51
- data/spec/provider/cloud66_spec.rb +0 -44
- data/spec/provider/cloud_files_spec.rb +0 -88
- data/spec/provider/cloudfoundry_spec.rb +0 -71
- data/spec/provider/code_deploy_spec.rb +0 -366
- data/spec/provider/deis_spec.rb +0 -116
- data/spec/provider/divshot_spec.rb +0 -28
- data/spec/provider/elastic_beanstalk_spec.rb +0 -209
- data/spec/provider/firebase_spec.rb +0 -40
- data/spec/provider/gae_spec.rb +0 -26
- data/spec/provider/gcs_spec.rb +0 -115
- data/spec/provider/hackage_spec.rb +0 -47
- data/spec/provider/heroku_spec.rb +0 -357
- data/spec/provider/lambda_spec.rb +0 -432
- data/spec/provider/launchpad_spec.rb +0 -33
- data/spec/provider/modulus_spec.rb +0 -29
- data/spec/provider/npm_spec.rb +0 -95
- data/spec/provider/openshift_spec.rb +0 -91
- data/spec/provider/ops_works_spec.rb +0 -127
- data/spec/provider/packagecloud_spec.rb +0 -56
- data/spec/provider/puppet_forge_spec.rb +0 -60
- data/spec/provider/pypi_spec.rb +0 -105
- data/spec/provider/releases_spec.rb +0 -303
- data/spec/provider/rubygems_spec.rb +0 -106
- data/spec/provider/s3_spec.rb +0 -174
- data/spec/provider/scalingo_spec.rb +0 -64
- data/spec/provider/script_spec.rb +0 -26
- data/spec/provider/surge_spec.rb +0 -15
- data/spec/provider/testfairy_spec.rb +0 -65
- data/spec/provider/transifex_spec.rb +0 -110
@@ -1,51 +0,0 @@
|
|
1
|
-
module DPL
|
2
|
-
class Provider
|
3
|
-
class RubyGems < Provider
|
4
|
-
requires 'gems', version: '>= 0.8.3'
|
5
|
-
|
6
|
-
def setup_auth
|
7
|
-
::Gems.key = option(:api_key) if options[:api_key]
|
8
|
-
::Gems.username = option(:user) unless options[:api_key]
|
9
|
-
::Gems.password = option(:password) unless options[:api_key]
|
10
|
-
end
|
11
|
-
|
12
|
-
def needs_key?
|
13
|
-
false
|
14
|
-
end
|
15
|
-
|
16
|
-
def setup_gem
|
17
|
-
options[:gem] ||= options[:app]
|
18
|
-
end
|
19
|
-
|
20
|
-
def gemspec
|
21
|
-
options[:gemspec].gsub('.gemspec', '') if options[:gemspec]
|
22
|
-
end
|
23
|
-
|
24
|
-
def check_app
|
25
|
-
setup_auth
|
26
|
-
setup_gem
|
27
|
-
log "Looking up gem #{options[:gem]}"
|
28
|
-
info = ::Gems.info(options[:gem])
|
29
|
-
log "Found gem #{info['name']}"
|
30
|
-
end
|
31
|
-
|
32
|
-
def check_auth
|
33
|
-
setup_auth
|
34
|
-
log "Authenticated with username #{::Gems.username}" if ::Gems.username
|
35
|
-
end
|
36
|
-
|
37
|
-
def push_app
|
38
|
-
setup_auth
|
39
|
-
setup_gem
|
40
|
-
context.shell "gem build #{gemspec || option(:gem)}.gemspec"
|
41
|
-
Dir.glob("#{gemspec || option(:gem)}-*.gem") do |f|
|
42
|
-
if options[:host]
|
43
|
-
log ::Gems.push(File.new(f), options[:host])
|
44
|
-
else
|
45
|
-
log ::Gems.push(File.new f)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
data/lib/dpl/provider/s3.rb
DELETED
@@ -1,123 +0,0 @@
|
|
1
|
-
require 'json'
|
2
|
-
|
3
|
-
module DPL
|
4
|
-
class Provider
|
5
|
-
class S3 < Provider
|
6
|
-
requires 'aws-sdk', version: '~> 2.0'
|
7
|
-
requires 'mime-types', version: '~> 2.0'
|
8
|
-
|
9
|
-
def api
|
10
|
-
@api ||= ::Aws::S3::Resource.new(s3_options)
|
11
|
-
end
|
12
|
-
|
13
|
-
def needs_key?
|
14
|
-
false
|
15
|
-
end
|
16
|
-
|
17
|
-
def check_app
|
18
|
-
log 'Warning: The endpoint option is no longer used and can be removed.' if options[:endpoint]
|
19
|
-
end
|
20
|
-
|
21
|
-
def access_key_id
|
22
|
-
options[:access_key_id] || context.env['AWS_ACCESS_KEY_ID'] || raise(Error, "missing access_key_id")
|
23
|
-
end
|
24
|
-
|
25
|
-
def secret_access_key
|
26
|
-
options[:secret_access_key] || context.env['AWS_SECRET_ACCESS_KEY'] || raise(Error, "missing secret_access_key")
|
27
|
-
end
|
28
|
-
|
29
|
-
def s3_options
|
30
|
-
{
|
31
|
-
region: options[:region] || 'us-east-1',
|
32
|
-
credentials: ::Aws::Credentials.new(access_key_id, secret_access_key)
|
33
|
-
}
|
34
|
-
end
|
35
|
-
|
36
|
-
def check_auth
|
37
|
-
log "Logging in with Access Key: #{access_key_id[-4..-1].rjust(20, '*')}"
|
38
|
-
end
|
39
|
-
|
40
|
-
def upload_path(filename)
|
41
|
-
[options[:upload_dir], filename].compact.join("/")
|
42
|
-
end
|
43
|
-
|
44
|
-
def push_app
|
45
|
-
glob_args = ["**/*"]
|
46
|
-
glob_args << File::FNM_DOTMATCH if options[:dot_match]
|
47
|
-
Dir.chdir(options.fetch(:local_dir, Dir.pwd)) do
|
48
|
-
Dir.glob(*glob_args) do |filename|
|
49
|
-
opts = content_data_for(filename)
|
50
|
-
opts[:cache_control] = get_option_value_by_filename(options[:cache_control], filename) if options[:cache_control]
|
51
|
-
opts[:acl] = options[:acl].gsub(/_/, '-') if options[:acl]
|
52
|
-
opts[:expires] = get_option_value_by_filename(options[:expires], filename) if options[:expires]
|
53
|
-
opts[:storage_class] = options[:storage_class] if options[:storage_class]
|
54
|
-
opts[:server_side_encryption] = "AES256" if options[:server_side_encryption]
|
55
|
-
unless File.directory?(filename)
|
56
|
-
log "uploading #{filename.inspect} with #{opts.inspect}"
|
57
|
-
result = api.bucket(option(:bucket)).object(upload_path(filename)).upload_file(filename, opts)
|
58
|
-
warn "error while uploading #{filename.inspect}" unless result
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
if suffix = options[:index_document_suffix]
|
64
|
-
api.bucket(option(:bucket)).website.put(
|
65
|
-
website_configuration: {
|
66
|
-
index_document: {
|
67
|
-
suffix: suffix
|
68
|
-
}
|
69
|
-
}
|
70
|
-
)
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
def deploy
|
75
|
-
super
|
76
|
-
rescue ::Aws::S3::Errors::InvalidAccessKeyId
|
77
|
-
raise Error, "Invalid S3 Access Key Id, Stopping Deploy"
|
78
|
-
rescue ::Aws::S3::Errors::ChecksumError
|
79
|
-
raise Error, "Aws Secret Key does not match Access Key Id, Stopping Deploy"
|
80
|
-
rescue ::Aws::S3::Errors::AccessDenied
|
81
|
-
raise Error, "Oops, It looks like you tried to write to a bucket that isn't yours or doesn't exist yet. Please create the bucket before trying to write to it."
|
82
|
-
end
|
83
|
-
|
84
|
-
private
|
85
|
-
def content_data_for(path)
|
86
|
-
content_data = {}
|
87
|
-
content_type = MIME::Types.type_for(path).first
|
88
|
-
content_data[:content_type] = content_type.to_s
|
89
|
-
|
90
|
-
encoding = encoding_for(path)
|
91
|
-
if detect_encoding?
|
92
|
-
content_data[:content_encoding] = encoding if encoding
|
93
|
-
end
|
94
|
-
|
95
|
-
if encoding == 'text' && default_text_charset?
|
96
|
-
content_data[:content_type] = "#{content_data[:content_type]}; charset=#{default_text_charset}"
|
97
|
-
end
|
98
|
-
|
99
|
-
return content_data
|
100
|
-
end
|
101
|
-
|
102
|
-
def get_option_value_by_filename(option_values, filename)
|
103
|
-
return option_values if !option_values.kind_of?(Array)
|
104
|
-
preferred_value = nil
|
105
|
-
hashes = option_values.select {|value| value.kind_of?(Hash) }
|
106
|
-
hashes.each do |hash|
|
107
|
-
hash.each do |value, patterns|
|
108
|
-
unless patterns.kind_of?(Array)
|
109
|
-
patterns = [patterns]
|
110
|
-
end
|
111
|
-
patterns.each do |pattern|
|
112
|
-
if File.fnmatch?(pattern, filename)
|
113
|
-
preferred_value = value
|
114
|
-
end
|
115
|
-
end
|
116
|
-
end
|
117
|
-
end
|
118
|
-
preferred_value = option_values.select {|value| value.kind_of?(String) }.last if preferred_value.nil?
|
119
|
-
return preferred_value
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|
123
|
-
end
|
@@ -1,97 +0,0 @@
|
|
1
|
-
require 'net/http'
|
2
|
-
require 'uri'
|
3
|
-
require 'json'
|
4
|
-
require 'date'
|
5
|
-
|
6
|
-
module DPL
|
7
|
-
class Provider
|
8
|
-
class Scalingo < Provider
|
9
|
-
|
10
|
-
def install_deploy_dependencies
|
11
|
-
unless context.shell "curl -OL https://cli-dl.scalingo.io/release/scalingo_latest_linux_amd64.tar.gz && tar -zxvf scalingo_latest_linux_amd64.tar.gz && mv scalingo_*_linux_amd64/scalingo . && rm scalingo_latest_linux_amd64.tar.gz && rm -r scalingo_*_linux_amd64"
|
12
|
-
error "Couldn't install Scalingo CLI."
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
def initialize(context, options)
|
17
|
-
super
|
18
|
-
@options = options
|
19
|
-
@remote = options[:remote] || "scalingo"
|
20
|
-
@branch = options[:branch] || "master"
|
21
|
-
end
|
22
|
-
|
23
|
-
def logged_in
|
24
|
-
context.shell "DISABLE_INTERACTIVE=true ./scalingo login 2> /dev/null > /dev/null"
|
25
|
-
end
|
26
|
-
|
27
|
-
def check_auth
|
28
|
-
if @options[:api_key]
|
29
|
-
unless context.shell "mkdir -p ~/.config/scalingo"
|
30
|
-
error "Couldn't create authentication file."
|
31
|
-
end
|
32
|
-
url = URI.parse('http://api.scalingo.com/v1/users/self')
|
33
|
-
http = Net::HTTP.new(url.host, url.port)
|
34
|
-
request = Net::HTTP::Get.new(url.request_uri)
|
35
|
-
request.basic_auth("", @options[:api_key])
|
36
|
-
request["Accept"] = "application/json"
|
37
|
-
request["Content-type"] = "application/json"
|
38
|
-
response = http.request(request)
|
39
|
-
data = {}
|
40
|
-
if File.exist?("#{Dir.home}/.config/scalingo/auth")
|
41
|
-
data = JSON.parse(File.read("#{Dir.home}/.config/scalingo/auth"))
|
42
|
-
end
|
43
|
-
begin
|
44
|
-
user = JSON.parse(response.body)
|
45
|
-
rescue
|
46
|
-
error "Invalid API token."
|
47
|
-
end
|
48
|
-
data["auth_config_data"] = {}
|
49
|
-
data["auth_config_data"]["api.scalingo.com"] = {}
|
50
|
-
data["auth_config_data"]["api.scalingo.com"]["id"] = user["user"]["id"]
|
51
|
-
data["auth_config_data"]["api.scalingo.com"]["last_name"] = user["user"]["last_name"]
|
52
|
-
data["auth_config_data"]["api.scalingo.com"]["username"] = user["user"]["username"]
|
53
|
-
data["auth_config_data"]["api.scalingo.com"]["email"] = user["user"]["email"]
|
54
|
-
data["auth_config_data"]["api.scalingo.com"]["first_name"] = user["user"]["first_name"]
|
55
|
-
data["auth_config_data"]["api.scalingo.com"]["auth_token"] = @options[:api_key]
|
56
|
-
data["last_update"] = DateTime.now
|
57
|
-
f = File.open("#{Dir.home}/.config/scalingo/auth", "w+") {
|
58
|
-
|f| f.write(data.to_json)
|
59
|
-
}
|
60
|
-
elsif @options[:username] && @options[:password]
|
61
|
-
context.shell "echo -e \"#{@options[:username]}\n#{@options[:password]}\" | timeout 2 ./scalingo login 2> /dev/null > /dev/null"
|
62
|
-
end
|
63
|
-
if !logged_in
|
64
|
-
error "Couldn't connect to Scalingo API."
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
def setup_key(file, type = nil)
|
69
|
-
if !logged_in
|
70
|
-
error "Couldn't connect to Scalingo API."
|
71
|
-
end
|
72
|
-
unless context.shell "./scalingo keys-add dpl_tmp_key #{file}"
|
73
|
-
error "Couldn't add ssh key."
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
def remove_key
|
78
|
-
if !logged_in
|
79
|
-
error "Couldn't connect to Scalingo API."
|
80
|
-
end
|
81
|
-
unless context.shell "./scalingo keys-remove dpl_tmp_key"
|
82
|
-
error "Couldn't remove ssh key."
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
def push_app
|
87
|
-
if @options[:app]
|
88
|
-
context.shell "git remote add #{@remote} git@scalingo.com:#{@options[:app]}.git 2> /dev/null > /dev/null"
|
89
|
-
end
|
90
|
-
unless context.shell "git push #{@remote} #{@branch} -f"
|
91
|
-
error "Couldn't push your app."
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
data/lib/dpl/provider/script.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
module DPL
|
2
|
-
class Provider
|
3
|
-
class Script < Provider
|
4
|
-
|
5
|
-
experimental 'Script'
|
6
|
-
|
7
|
-
def check_auth
|
8
|
-
end
|
9
|
-
|
10
|
-
def check_app
|
11
|
-
end
|
12
|
-
|
13
|
-
def needs_key?
|
14
|
-
false
|
15
|
-
end
|
16
|
-
|
17
|
-
def push_app
|
18
|
-
context.shell script
|
19
|
-
if $?.exitstatus != 0
|
20
|
-
raise Error, "Script failed with status #{$?.exitstatus}"
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def script
|
25
|
-
options[:script]
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
data/lib/dpl/provider/surge.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
module DPL
|
2
|
-
class Provider
|
3
|
-
class Surge < Provider
|
4
|
-
npm_g 'surge'
|
5
|
-
|
6
|
-
def project
|
7
|
-
File.expand_path( (context.env['TRAVIS_BUILD_DIR'] || '.' ) + "/" + (options[:project] || '') )
|
8
|
-
end
|
9
|
-
|
10
|
-
def domain
|
11
|
-
options[:domain] || ''
|
12
|
-
end
|
13
|
-
|
14
|
-
def check_auth
|
15
|
-
if ! context.env['SURGE_TOKEN'] then raise Error, "Please add SURGE_TOKEN in Travis settings (get your token with 'surge token')" end
|
16
|
-
if ! context.env['SURGE_LOGIN'] then raise Error, "Please add SURGE_LOGIN in Travis settings (its your email)" end
|
17
|
-
end
|
18
|
-
|
19
|
-
def check_app
|
20
|
-
if ! File.directory?(project) then raise Error, "Please set a valid project folder path in .travis.yml under deploy: project: myPath" end
|
21
|
-
if domain.empty? && ! File.exist?("#{project}/CNAME") then raise Error, "Please set domain in .travis.yml under deploy: project: myDomain (or in a CNAME file in the repo project folder)" end
|
22
|
-
end
|
23
|
-
|
24
|
-
def needs_key?
|
25
|
-
false
|
26
|
-
end
|
27
|
-
|
28
|
-
def push_app
|
29
|
-
context.shell "surge #{project} #{domain}"
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
@@ -1,111 +0,0 @@
|
|
1
|
-
module DPL
|
2
|
-
class Provider
|
3
|
-
class TestFairy < Provider
|
4
|
-
|
5
|
-
requires "multipart-post", load: 'net/http/post/multipart', version: '2.0.0'
|
6
|
-
|
7
|
-
require "net/http"
|
8
|
-
require 'net/http/post/multipart'
|
9
|
-
require 'json'
|
10
|
-
|
11
|
-
|
12
|
-
VERSION = "0.2"
|
13
|
-
TAG = "-TestFairy-"
|
14
|
-
SERVER = "http://api.testfairy.com"
|
15
|
-
UPLOAD_URL_PATH = "/api/upload";
|
16
|
-
|
17
|
-
def check_auth
|
18
|
-
if !options[:app_file]
|
19
|
-
error 'App file is missing'
|
20
|
-
end
|
21
|
-
puts "api-key = #{option(:api_key).gsub(/[123456789]/, '*')} symbols-file = #{options[:symbols_file]}"
|
22
|
-
end
|
23
|
-
|
24
|
-
def needs_key?
|
25
|
-
false
|
26
|
-
end
|
27
|
-
|
28
|
-
def push_app
|
29
|
-
puts "push_app #{TAG}"
|
30
|
-
response = upload_app
|
31
|
-
puts "Upload success!, check your build on #{response['build_url']}"
|
32
|
-
end
|
33
|
-
|
34
|
-
def android?
|
35
|
-
option(:app_file).include? "apk"
|
36
|
-
end
|
37
|
-
|
38
|
-
|
39
|
-
private
|
40
|
-
|
41
|
-
def upload_app
|
42
|
-
uploadUrl = SERVER + UPLOAD_URL_PATH
|
43
|
-
params = get_params
|
44
|
-
post uploadUrl, params
|
45
|
-
end
|
46
|
-
|
47
|
-
def post url, params
|
48
|
-
puts "Upload parameters = #{get_printable_params params} \nto #{url}"
|
49
|
-
uri = URI.parse(url)
|
50
|
-
request = Net::HTTP::Post::Multipart.new(uri.path, params, 'User-Agent' => "Travis plugin version=#{VERSION}")
|
51
|
-
res = Net::HTTP.start(uri.host, uri.port) do |http|
|
52
|
-
http.request(request)
|
53
|
-
end
|
54
|
-
puts res.body
|
55
|
-
resBody = JSON.parse(res.body)
|
56
|
-
if (resBody['status'] == 'fail')
|
57
|
-
raise Error, resBody['message']
|
58
|
-
end
|
59
|
-
return resBody
|
60
|
-
end
|
61
|
-
|
62
|
-
def get_printable_params params
|
63
|
-
paramsToPrint = params.clone
|
64
|
-
paramsToPrint['api_key'] = paramsToPrint['api_key'].gsub(/[123456789]/, '*')
|
65
|
-
paramsToPrint['apk_file'] = paramsToPrint['apk_file'].path()
|
66
|
-
JSON.pretty_generate(paramsToPrint)
|
67
|
-
end
|
68
|
-
|
69
|
-
def get_params
|
70
|
-
params = {'api_key' => "#{option(:api_key)}"}
|
71
|
-
add_file_param params, 'apk_file', option(:app_file)
|
72
|
-
add_file_param params, 'symbols_file', options[:symbols_file]
|
73
|
-
add_param params, 'video-quality', options[:video_quality]
|
74
|
-
add_param params, 'screenshot-interval', options[:screenshot_interval]
|
75
|
-
add_param params, 'max-duration', options[:max_duration]
|
76
|
-
add_param params, 'testers-groups', options[:testers_groups]
|
77
|
-
add_param params, 'metrics', options[:metrics]
|
78
|
-
add_boolean_param params, 'data-only-wifi', options[:data_only_wifi]
|
79
|
-
add_boolean_param params, 'record-on-background', options[:record_on_background]
|
80
|
-
add_boolean_param params, 'video', options[:video]
|
81
|
-
add_boolean_param params, 'notify', options[:notify]
|
82
|
-
add_boolean_param params, 'auto-update', options[:auto_update]
|
83
|
-
|
84
|
-
travisCommitRange = context.env.fetch('TRAVIS_COMMIT_RANGE',nil)
|
85
|
-
if !travisCommitRange.nil?
|
86
|
-
changelog = %x[git log --pretty=oneline --abbrev-commit #{travisCommitRange}]
|
87
|
-
add_param params, 'changelog', changelog
|
88
|
-
end
|
89
|
-
params
|
90
|
-
end
|
91
|
-
|
92
|
-
def add_file_param params, fileName, filePath
|
93
|
-
if (!filePath.nil? && !filePath.empty?)
|
94
|
-
params[fileName] = UploadIO.new(File.new(filePath), "", filePath.split("/").last)
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
def add_param params, paramName, param
|
99
|
-
if (!param.nil? && !param.empty?)
|
100
|
-
params[paramName] = param
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
def add_boolean_param params, paramName, param
|
105
|
-
if (!param.nil?)
|
106
|
-
params[paramName] = (param == true) ? "on" : "off"
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|