Skip to content
This repository has been archived by the owner on Jun 28, 2018. It is now read-only.

Commit

Permalink
Merge branch 'rm-v1-metadata-upload'
Browse files Browse the repository at this point in the history
  • Loading branch information
danielsdeleo committed Mar 27, 2013
2 parents dc8613e + 8cfca36 commit 695350a
Showing 1 changed file with 12 additions and 49 deletions.
61 changes: 12 additions & 49 deletions jenkins/release.rb
Original file line number Diff line number Diff line change
Expand Up @@ -213,20 +213,14 @@ def release_it
artifact_collection = ArtifactCollection.new(options[:project], options)
artifacts = artifact_collection.artifacts

metadata = {}
v2_metadata = {}

artifacts.each do |artifact|
artifact.add_to_release_manifest!(metadata)
artifact.add_to_v2_release_manifest!(v2_metadata)
upload_package(artifact.path, artifact.relpath)
end
upload_platform_name_map(artifact_collection.platform_name_map_path)
upload_manifest(metadata)
if upload_v2_manifest?
upload_v2_platform_name_map(artifact_collection.platform_name_map_path)
upload_v2_manifest(v2_metadata)
end
upload_v2_platform_name_map(artifact_collection.platform_name_map_path)
upload_v2_manifest(v2_metadata)
end

def option_parser
Expand Down Expand Up @@ -274,18 +268,7 @@ def parse_options
options[:version] = IO.read(build_version_file).chomp if build_version_file
end

# metadata bucket and config file must be configured together
# TODO: these will be non-optional when we complete the transition from v1
# to v2 metadata.
if (options[:metadata_bucket].nil? ^ options[:metadata_s3_config_file].nil?)
puts "You must specify *both* metadata-bucket and metadata-s3-config to upload v2 metadata"
puts "If you don't want to upload v2 metadata, don't specify either of these options"
puts ""
puts option_parser
exit 1
end

required = [:project, :version, :bucket]
required = [:project, :version, :bucket, :metadata_bucket, :metadata_s3_config_file]
missing = required.select {|param| options[param].nil?}
if !missing.empty?
puts "Missing required options: #{missing.join(', ')}"
Expand All @@ -302,11 +285,19 @@ def shellout_opts
{:timeout => 1200, :live_stream => STDOUT}
end

def progress
if STDOUT.tty?
"--progress"
else
"--no-progress"
end
end

def upload_package(local_path, s3_path)
s3_cmd = ["s3cmd",
"-c #{options[:package_s3_config_file]}",
"put",
"--progress",
progress,
"--acl-public",
local_path,
"s3://#{options[:bucket]}#{s3_path}"].join(" ")
Expand All @@ -315,20 +306,6 @@ def upload_package(local_path, s3_path)
shell.error!
end

def upload_manifest(manifest)
File.open("platform-support.json", "w") {|f| f.puts JSON.pretty_generate(manifest)}

s3_location = "s3://#{options[:bucket]}/#{options[:project]}-platform-support/#{options[:version]}.json"
puts "UPLOAD: platform-support.json -> #{s3_location}"
s3_cmd = ["s3cmd",
"put",
"platform-support.json",
s3_location].join(" ")
shell = Mixlib::ShellOut.new(s3_cmd, shellout_opts)
shell.run_command
shell.error!
end

def upload_v2_manifest(manifest)
File.open("v2-release-manifest.json", "w") {|f| f.puts JSON.pretty_generate(manifest)}

Expand Down Expand Up @@ -359,20 +336,6 @@ def upload_v2_platform_name_map(platform_names_file)
shell.error!
end

# Legacy v1 platform name map. This can be removed when v2 goes live.
def upload_platform_name_map(platform_names_file)
s3_location = "s3://#{options[:bucket]}/#{options[:project]}-platform-support/#{options[:project]}-platform-names.json"
puts "UPLOAD: #{options[:project]}-platform-names.json -> #{s3_location}"
s3_cmd = ["s3cmd",
"-c #{options[:package_s3_config_file]}",
"put",
platform_names_file,
s3_location].join(" ")
shell = Mixlib::ShellOut.new(s3_cmd, shellout_opts)
shell.run_command
shell.error!
end

def upload_v2_manifest?
!options[:metadata_bucket].nil?
end
Expand Down

0 comments on commit 695350a

Please sign in to comment.