Permalink
Browse files

Merge branch 'rm-v1-metadata-upload'

  • Loading branch information...
2 parents dc8613e + 8cfca36 commit 695350a914861e651524a25f514b74bb7f91c0e4 @danielsdeleo danielsdeleo committed Mar 27, 2013
Showing with 12 additions and 49 deletions.
  1. +12 −49 jenkins/release.rb
View
@@ -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
@@ -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(', ')}"
@@ -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(" ")
@@ -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)}
@@ -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

0 comments on commit 695350a

Please sign in to comment.