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,22 +0,0 @@
|
|
1
|
-
module DPL
|
2
|
-
class Provider
|
3
|
-
class BitBalloon < Provider
|
4
|
-
requires 'bitballoon'
|
5
|
-
|
6
|
-
def check_auth
|
7
|
-
end
|
8
|
-
|
9
|
-
def needs_key?
|
10
|
-
false
|
11
|
-
end
|
12
|
-
|
13
|
-
def push_app
|
14
|
-
command = 'bitballoon deploy'
|
15
|
-
command << " ./#{option(:local_dir)}" if options.fetch(:local_dir,false)
|
16
|
-
command << " --site-id=#{option(:site_id)}" if options[:site_id]
|
17
|
-
command << " --access-token=#{option(:access_token)}" if options[:access_token]
|
18
|
-
context.shell command
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
module DPL
|
2
|
-
class Provider
|
3
|
-
class BluemixCloudFoundry < CloudFoundry
|
4
|
-
|
5
|
-
REGIONS = Hash.new {"api.ng.bluemix.net"}.update(
|
6
|
-
"eu-gb" => "api.eu-gb.bluemix.net",
|
7
|
-
"eu-de" => "api.eu-de.bluemix.net",
|
8
|
-
"au-syd" => "api.au-syd.bluemix.net"
|
9
|
-
)
|
10
|
-
|
11
|
-
def set_api
|
12
|
-
region = options[:region] || "ng"
|
13
|
-
options[:api] = options[:api] || REGIONS[region]
|
14
|
-
end
|
15
|
-
|
16
|
-
def check_auth
|
17
|
-
set_api
|
18
|
-
super
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
data/lib/dpl/provider/boxfuse.rb
DELETED
@@ -1,57 +0,0 @@
|
|
1
|
-
module DPL
|
2
|
-
class Provider
|
3
|
-
class Boxfuse < Provider
|
4
|
-
|
5
|
-
def deploy
|
6
|
-
@user = options[:user]
|
7
|
-
@secret = options[:secret]
|
8
|
-
@configfile = options[:configfile]
|
9
|
-
@payload = options[:payload]
|
10
|
-
@image = options[:image]
|
11
|
-
@env = options[:env]
|
12
|
-
@extra_args = options[:extra_args]
|
13
|
-
|
14
|
-
@param_user = ''
|
15
|
-
if @user.to_s != ''
|
16
|
-
@param_user = " -user=" + @user
|
17
|
-
end
|
18
|
-
|
19
|
-
@param_secret = ''
|
20
|
-
if @secret.to_s != ''
|
21
|
-
@param_secret = " -secret=" + @secret
|
22
|
-
end
|
23
|
-
|
24
|
-
@param_configfile = ''
|
25
|
-
if @configfile.to_s != ''
|
26
|
-
@param_configfile = ' "-configfile=' + @configfile + '"'
|
27
|
-
end
|
28
|
-
|
29
|
-
@param_payload = ''
|
30
|
-
if @payload.to_s != ''
|
31
|
-
@param_payload = ' "' + @payload + '"'
|
32
|
-
end
|
33
|
-
|
34
|
-
@param_image = ''
|
35
|
-
if @image.to_s != ''
|
36
|
-
@param_image = " -image=" + @image
|
37
|
-
end
|
38
|
-
|
39
|
-
@param_env = ' -env=test'
|
40
|
-
if @env.to_s != ''
|
41
|
-
@param_env = " -env=" + @env
|
42
|
-
end
|
43
|
-
|
44
|
-
@param_extra_args = ''
|
45
|
-
if @extra_args.to_s != ''
|
46
|
-
@param_extra_args = " " + @extra_args
|
47
|
-
end
|
48
|
-
|
49
|
-
context.shell "curl -L https://files.boxfuse.com/com/boxfuse/client/boxfuse-commandline/latest/boxfuse-commandline-latest-linux-x64.tar.gz | tar xz"
|
50
|
-
|
51
|
-
@command = "boxfuse/boxfuse run" + @param_user + @param_secret + @param_configfile + @param_payload + @param_image + @param_env + @param_extra_args
|
52
|
-
context.fold("Deploying application") { context.shell @command }
|
53
|
-
end
|
54
|
-
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
@@ -1,49 +0,0 @@
|
|
1
|
-
module DPL
|
2
|
-
class Provider
|
3
|
-
class Catalyze < Provider
|
4
|
-
def config
|
5
|
-
{
|
6
|
-
# the git repository to deploy to
|
7
|
-
"target" => options[:target] || context.env['CATALYZE_TARGET'],
|
8
|
-
# the pathspec for files to add to git for deployment e.g. your build directory. defaults to all files.
|
9
|
-
"path" => options[:path] || context.env['CATALYZE_PATH'] || '.'
|
10
|
-
}
|
11
|
-
end
|
12
|
-
|
13
|
-
def needs_key?
|
14
|
-
false
|
15
|
-
end
|
16
|
-
|
17
|
-
def check_app
|
18
|
-
end
|
19
|
-
|
20
|
-
def check_auth
|
21
|
-
error "Missing Catalyze target" unless config['target']
|
22
|
-
end
|
23
|
-
|
24
|
-
def push_app
|
25
|
-
log "Deploying to Catalyze '#{config['target']}'"
|
26
|
-
|
27
|
-
if options[:skip_cleanup]
|
28
|
-
# create commit message
|
29
|
-
build_num = context.env["TRAVIS_BUILD_NUMBER"]
|
30
|
-
commit = context.env["TRAVIS_COMMIT"]
|
31
|
-
repo_slug = context.env["TRAVIS_REPO_SLUG"]
|
32
|
-
branch = context.env["TRAVIS_BRANCH"]
|
33
|
-
if build_num && commit && repo_slug && branch
|
34
|
-
commit_message = "Build ##{build_num} (#{commit}) of #{repo_slug}@#{branch}"
|
35
|
-
else
|
36
|
-
commit_message = "Local build"
|
37
|
-
end
|
38
|
-
|
39
|
-
log "Using build files for deployment"
|
40
|
-
context.shell "git checkout HEAD"
|
41
|
-
context.shell "git add #{config["path"]} --all --force"
|
42
|
-
context.shell "git commit -m \"#{commit_message}\" --quiet"
|
43
|
-
end
|
44
|
-
|
45
|
-
context.shell "git push --force #{config['target']} HEAD:master"
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
@@ -1,85 +0,0 @@
|
|
1
|
-
module DPL
|
2
|
-
class Provider
|
3
|
-
class ChefSupermarket < Provider
|
4
|
-
|
5
|
-
# Most of the code is inspired by:
|
6
|
-
# https://github.com/opscode/chef/blob/11.16.4/lib/chef/knife/cookbook_site_share.rb
|
7
|
-
|
8
|
-
# Compatibility with ruby 1.9
|
9
|
-
requires 'rack', version: '< 2.0'
|
10
|
-
requires 'mime-types', version: '~> 1.16'
|
11
|
-
requires 'chef', version: '< 12.0'
|
12
|
-
requires 'chef', load: 'chef/config'
|
13
|
-
requires 'chef', load: 'chef/cookbook_loader'
|
14
|
-
requires 'chef', load: 'chef/cookbook_uploader'
|
15
|
-
requires 'chef', load: 'chef/cookbook_site_streaming_uploader'
|
16
|
-
|
17
|
-
attr_reader :cookbook_name, :cookbook_category
|
18
|
-
attr_reader :cookbook
|
19
|
-
|
20
|
-
def needs_key?
|
21
|
-
false
|
22
|
-
end
|
23
|
-
|
24
|
-
def check_auth
|
25
|
-
error "Missing user_id option" unless options[:user_id]
|
26
|
-
error "Missing client_key option" unless options[:client_key]
|
27
|
-
::Chef::Config[:client_key] = options[:client_key]
|
28
|
-
error "#{options[:client_key]} does not exist" unless ::File.exist?(options[:client_key])
|
29
|
-
end
|
30
|
-
|
31
|
-
def check_app
|
32
|
-
@cookbook_name = options[:cookbook_name] || options[:app]
|
33
|
-
@cookbook_category = options[:cookbook_category]
|
34
|
-
unless cookbook_category
|
35
|
-
error "Missing cookbook_category option\n" +
|
36
|
-
"see https://docs.getchef.com/knife_cookbook_site.html#id12"
|
37
|
-
end
|
38
|
-
|
39
|
-
log "Validating cookbook #{cookbook_name}"
|
40
|
-
# Check that cookbook exist and is valid
|
41
|
-
# So we assume cookbook path is '..'
|
42
|
-
cl = ::Chef::CookbookLoader.new '..'
|
43
|
-
@cookbook = cl[cookbook_name]
|
44
|
-
::Chef::CookbookUploader.new(cookbook, '..').validate_cookbooks
|
45
|
-
end
|
46
|
-
|
47
|
-
def push_app
|
48
|
-
log "Creating cookbook build directory"
|
49
|
-
tmp_cookbook_dir = Chef::CookbookSiteStreamingUploader.create_build_dir(cookbook)
|
50
|
-
log "Making tarball in #{tmp_cookbook_dir}"
|
51
|
-
system("tar -czf #{cookbook_name}.tgz #{cookbook_name}", :chdir => tmp_cookbook_dir)
|
52
|
-
|
53
|
-
uri = "https://supermarket.chef.io/api/v1/cookbooks"
|
54
|
-
|
55
|
-
log "Uploading to #{uri}"
|
56
|
-
category_string = { 'category'=>cookbook_category }.to_json
|
57
|
-
http_resp = ::Chef::CookbookSiteStreamingUploader.post(
|
58
|
-
uri,
|
59
|
-
options[:user_id],
|
60
|
-
options[:client_key],
|
61
|
-
{
|
62
|
-
:tarball => File.open("#{tmp_cookbook_dir}/#{cookbook_name}.tgz"),
|
63
|
-
:cookbook => category_string
|
64
|
-
}
|
65
|
-
)
|
66
|
-
res = ::Chef::JSONCompat.from_json(http_resp.body)
|
67
|
-
if http_resp.code.to_i != 201
|
68
|
-
if res['error_messages']
|
69
|
-
if res['error_messages'][0] =~ /Version already exists/
|
70
|
-
error "The same version of this cookbook already exists on the Opscode Cookbook Site."
|
71
|
-
else
|
72
|
-
error "#{res['error_messages'][0]}"
|
73
|
-
end
|
74
|
-
else
|
75
|
-
error "Unknown error while sharing cookbook\n" +
|
76
|
-
"Server response: #{http_resp.body}"
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
log "Upload complete."
|
81
|
-
::FileUtils.rm_rf tmp_cookbook_dir
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
data/lib/dpl/provider/cloud66.rb
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
require 'net/http'
|
2
|
-
require 'net/https'
|
3
|
-
|
4
|
-
module DPL
|
5
|
-
class Provider
|
6
|
-
class Cloud66 < Provider
|
7
|
-
def needs_key?
|
8
|
-
false
|
9
|
-
end
|
10
|
-
|
11
|
-
def push_app
|
12
|
-
uri = URI.parse(redeployment_hook)
|
13
|
-
|
14
|
-
response = webhook_call(uri.scheme, uri.host, uri.port, uri.path)
|
15
|
-
|
16
|
-
error("Redeployment failed [#{response.code}]") if response.code != '200'
|
17
|
-
end
|
18
|
-
|
19
|
-
def check_auth
|
20
|
-
end
|
21
|
-
|
22
|
-
private
|
23
|
-
|
24
|
-
def webhook_call(scheme, host, port, path)
|
25
|
-
http = Net::HTTP.new(host, port)
|
26
|
-
http.use_ssl = (scheme.downcase == 'https')
|
27
|
-
|
28
|
-
request = Net::HTTP::Post.new(path)
|
29
|
-
|
30
|
-
return http.request(request)
|
31
|
-
end
|
32
|
-
|
33
|
-
def redeployment_hook
|
34
|
-
option(:redeployment_hook)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
require 'dpl/provider'
|
2
|
-
|
3
|
-
module DPL
|
4
|
-
class Provider
|
5
|
-
class CloudFiles < Provider
|
6
|
-
requires 'net-ssh', load: 'net/ssh', version: '~> 2.9.2' # Anything higher requires Ruby 2.x
|
7
|
-
requires 'mime-types', load: 'mime/types', version: '~> 2.6.2' # Anything higher requires Ruby 2.x
|
8
|
-
requires 'nokogiri', version: '~> 1.6.8.1' # 1.7.0 and up requires Ruby 2.1.0 (via fog-xml)
|
9
|
-
requires 'fog-rackspace', load: 'fog/rackspace'
|
10
|
-
experimental 'Rackspace Cloud Files'
|
11
|
-
|
12
|
-
def needs_key?
|
13
|
-
false
|
14
|
-
end
|
15
|
-
|
16
|
-
def api
|
17
|
-
@api ||= Fog::Storage.new(:provider => 'Rackspace', :rackspace_username => option(:username), :rackspace_api_key => option(:api_key), :rackspace_region => option(:region))
|
18
|
-
end
|
19
|
-
|
20
|
-
def check_auth
|
21
|
-
log "Authenticated as #{option(:username)}"
|
22
|
-
end
|
23
|
-
|
24
|
-
def push_app
|
25
|
-
container = api.directories.get(option(:container))
|
26
|
-
|
27
|
-
raise Error, 'The specified container does not exist.' if container.nil?
|
28
|
-
|
29
|
-
glob_args = ['**/*']
|
30
|
-
glob_args << File::FNM_DOTMATCH if options[:dot_match]
|
31
|
-
|
32
|
-
Dir.glob(*glob_args).each do |name|
|
33
|
-
container.files.create(:key => name, :body => File.open(name)) unless File.directory?(name)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
module DPL
|
2
|
-
class Provider
|
3
|
-
class CloudFoundry < Provider
|
4
|
-
|
5
|
-
def initial_go_tools_install
|
6
|
-
context.shell 'test x$TRAVIS_OS_NAME = "xlinux" && rel="linux64-binary" || rel="macosx64"; wget "https://cli.run.pivotal.io/stable?release=${rel}&source=github" -qO cf.tgz && tar -zxvf cf.tgz && rm cf.tgz'
|
7
|
-
end
|
8
|
-
|
9
|
-
def check_auth
|
10
|
-
initial_go_tools_install
|
11
|
-
context.shell "./cf api #{option(:api)} #{'--skip-ssl-validation' if options[:skip_ssl_validation]}"
|
12
|
-
context.shell "./cf login -u #{option(:username)} -p #{option(:password)} -o #{option(:organization)} -s #{option(:space)}"
|
13
|
-
end
|
14
|
-
|
15
|
-
def check_app
|
16
|
-
if options[:manifest]
|
17
|
-
error 'Application must have a manifest.yml for unattended deployment' unless File.exists? options[:manifest]
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def needs_key?
|
22
|
-
false
|
23
|
-
end
|
24
|
-
|
25
|
-
def push_app
|
26
|
-
error 'Failed to push app' unless context.shell("./cf push#{manifest}")
|
27
|
-
|
28
|
-
ensure
|
29
|
-
context.shell "./cf logout"
|
30
|
-
end
|
31
|
-
|
32
|
-
def cleanup
|
33
|
-
end
|
34
|
-
|
35
|
-
def uncleanup
|
36
|
-
end
|
37
|
-
|
38
|
-
def manifest
|
39
|
-
options[:manifest].nil? ? "" : " -f #{options[:manifest]}"
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
@@ -1,154 +0,0 @@
|
|
1
|
-
require 'json'
|
2
|
-
|
3
|
-
module DPL
|
4
|
-
class Provider
|
5
|
-
class CodeDeploy < Provider
|
6
|
-
requires 'aws-sdk', pre: true, version: '~> 2.0'
|
7
|
-
|
8
|
-
def code_deploy
|
9
|
-
@code_deploy ||= Aws::CodeDeploy::Client.new(code_deploy_options)
|
10
|
-
end
|
11
|
-
|
12
|
-
def s3api
|
13
|
-
@s3api ||= Aws::S3::Client.new(code_deploy_options)
|
14
|
-
end
|
15
|
-
|
16
|
-
def code_deploy_options
|
17
|
-
code_deploy_options = {
|
18
|
-
region: options[:region] || 'us-east-1',
|
19
|
-
credentials: Aws::Credentials.new(access_key_id, secret_access_key)
|
20
|
-
}
|
21
|
-
code_deploy_options[:endpoint] = options[:endpoint] if options[:endpoint]
|
22
|
-
code_deploy_options
|
23
|
-
end
|
24
|
-
|
25
|
-
def access_key_id
|
26
|
-
options[:access_key_id] || context.env['AWS_ACCESS_KEY_ID'] || raise(Error, "missing access_key_id")
|
27
|
-
end
|
28
|
-
|
29
|
-
def secret_access_key
|
30
|
-
options[:secret_access_key] || context.env['AWS_SECRET_ACCESS_KEY'] || raise(Error, "missing secret_access_key")
|
31
|
-
end
|
32
|
-
|
33
|
-
def needs_key?
|
34
|
-
false
|
35
|
-
end
|
36
|
-
|
37
|
-
def revision
|
38
|
-
case options[:revision_type].to_s.downcase
|
39
|
-
when "s3" then s3_revision
|
40
|
-
when "github" then github_revision
|
41
|
-
when "" then options[:bucket] ? s3_revision : github_revision
|
42
|
-
else error("unknown revision type %p" % options[:revision_type])
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
def revision_version_info
|
47
|
-
s3api.head_object({
|
48
|
-
bucket: option(:bucket),
|
49
|
-
key: s3_key
|
50
|
-
})
|
51
|
-
rescue Aws::Errors::ServiceError
|
52
|
-
{}
|
53
|
-
end
|
54
|
-
|
55
|
-
def s3_revision
|
56
|
-
info = {
|
57
|
-
revision_type: 'S3',
|
58
|
-
s3_location: {
|
59
|
-
bucket: option(:bucket),
|
60
|
-
bundle_type: bundle_type,
|
61
|
-
key: s3_key,
|
62
|
-
}
|
63
|
-
}
|
64
|
-
unless revision_version_info.empty?
|
65
|
-
info[:s3_location][:version] = revision_version_info[:version_id]
|
66
|
-
info[:s3_location][:e_tag] = revision_version_info[:etag]
|
67
|
-
end
|
68
|
-
|
69
|
-
info
|
70
|
-
end
|
71
|
-
|
72
|
-
def github_revision
|
73
|
-
{
|
74
|
-
revision_type: 'GitHub',
|
75
|
-
git_hub_location: {
|
76
|
-
commit_id: options[:commit_id] || context.env['TRAVIS_COMMIT'] || `git rev-parse HEAD`.strip,
|
77
|
-
repository: options[:repository] || context.env['TRAVIS_REPO_SLUG'] || option(:repository)
|
78
|
-
}
|
79
|
-
}
|
80
|
-
end
|
81
|
-
|
82
|
-
def push_app
|
83
|
-
rev = revision()
|
84
|
-
rev_info = rev[:s3_location]
|
85
|
-
|
86
|
-
if rev_info && rev_info[:version]
|
87
|
-
log "Registering app revision with version=#{rev_info[:version]}, etag=#{rev_info[:e_tag]}"
|
88
|
-
code_deploy.register_application_revision({
|
89
|
-
revision: rev,
|
90
|
-
application_name: options[:application] || option(:application_name),
|
91
|
-
description: options[:description] || default_description
|
92
|
-
})
|
93
|
-
end
|
94
|
-
|
95
|
-
data = code_deploy.create_deployment({
|
96
|
-
revision: revision,
|
97
|
-
application_name: options[:application] || option(:application_name),
|
98
|
-
deployment_group_name: options[:deployment_group] || option(:deployment_group_name),
|
99
|
-
description: options[:description] || default_description
|
100
|
-
})
|
101
|
-
log "Triggered deployment #{data.deployment_id.inspect}."
|
102
|
-
return unless options[:wait_until_deployed]
|
103
|
-
print "Deploying "
|
104
|
-
deployment = wait_until_deployed(data[:deployment_id])
|
105
|
-
print "\n"
|
106
|
-
if deployment[:status] == 'Succeeded'
|
107
|
-
log "Deployment successful."
|
108
|
-
else
|
109
|
-
error "Deployment failed."
|
110
|
-
end
|
111
|
-
rescue Aws::CodeDeploy::Errors::DeploymentLimitExceededException => exception
|
112
|
-
error(exception.message)
|
113
|
-
end
|
114
|
-
|
115
|
-
def wait_until_deployed(deployment_id)
|
116
|
-
deployment = {}
|
117
|
-
loop do
|
118
|
-
result = code_deploy.get_deployment(deployment_id: deployment_id)
|
119
|
-
deployment = result[:deployment_info]
|
120
|
-
break if deployment[:status] == "Succeeded" || deployment[:status] == "Failed" || deployment[:status] == "Stopped"
|
121
|
-
print "."
|
122
|
-
sleep 5
|
123
|
-
end
|
124
|
-
deployment
|
125
|
-
end
|
126
|
-
|
127
|
-
def bundle_type
|
128
|
-
if s3_key =~ /\.(tar|tgz|zip)$/
|
129
|
-
options[:bundle_type] || $1
|
130
|
-
else
|
131
|
-
option(:bundle_type)
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
def s3_key
|
136
|
-
options[:key] || option(:s3_key)
|
137
|
-
end
|
138
|
-
|
139
|
-
def default_description
|
140
|
-
"Deploy build #{context.env['TRAVIS_BUILD_NUMBER']} via Travis CI"
|
141
|
-
end
|
142
|
-
|
143
|
-
def check_auth
|
144
|
-
log "Logging in with Access Key: #{access_key_id[-4..-1].rjust(20, '*')}"
|
145
|
-
end
|
146
|
-
|
147
|
-
def cleanup
|
148
|
-
end
|
149
|
-
|
150
|
-
def uncleanup
|
151
|
-
end
|
152
|
-
end
|
153
|
-
end
|
154
|
-
end
|