Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding s3 upload to Rakefile and add buildkite shell script #429

Merged
merged 1 commit into from
Aug 27, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,13 @@ task :upload_box, :metadata_file do |f, args|
upload_to_atlas(metadata['name'], metadata['version'], metadata['providers'])
end

desc 'Release all boxes for a version'
desc 'Upload box files to S3 for all providers'
task :upload_box_s3, :metadata_file do |f, args|
metadata = box_metadata(args[:metadata_file])
upload_to_s3(metadata['name'], metadata['version'], metadata['providers'])
end

desc 'Release all boxes for a given version'
task :release_all do
metadata_files.each do |metadata_file|
puts "Processing #{metadata_file} for release."
Expand Down Expand Up @@ -215,6 +221,18 @@ def create_providers(boxname, version, provider_names)
end
end

def upload_to_s3(boxname, version, providers)
providers.each do |provider, provider_data|
boxfile = provider_data['file']
upload_path = "s3://opscode-vm-bento/vagrant/#{provider}/opscode_#{boxname}_chef-provisionerless.box"
puts "Uploading the box #{boxfile} to S3, version: #{version}, provider: #{provider}, upload path: #{upload_path}"
cmd = %W[s3cmd put builds/#{boxfile} #{upload_path}]
cmd.insert(1, ".s3cfg-bento")
cmd.insert(1, "--config")
sh cmd.join(' ')
end
end

def upload_to_atlas(boxname, version, providers)
# Extract the upload path
providers.each do |provider, provider_data|
Expand Down
74 changes: 74 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/usr/local/bin/bash

set -eo pipefail

env

source ~/.bashrc

function inline_image {
printf '\033]1338;url='"$1"';alt='"$2"'\a\n'
}

inline_image 'https://oaxacaborn.files.wordpress.com/2012/02/clean-all-the-things-via-hyperbole-and-a-half.png' 'Clean All The Things'


echo "--- Cleaning up after VirtualBox"

for i in `vboxmanage list runningvms | awk '{print $1}' | sed 's/"//g'`
do
echo "Powering off $i"
vboxmanage controlvm $i poweroff
done

for i in `vboxmanage list vms | awk '{print $1}' | sed 's/"//g'`
do
echo "Unregistering $i"
sleep 10
vboxmanage unregistervm $i
done

for i in `ls ~/VirtualBox\ VMs/`
do
echo "Removing $i"
rm -rf ~/VirtualBox\ VMs/$i
done

echo "--- Cleaning up after Parallels"

for i in `prlctl list --no-header --output name`
do
echo "Powering off $i"
prlctl stop $i --kill
sleep 10
done

for i in `prlctl list --all --no-header --output uuid`
do
echo "Unregistering $i"
prlctl unregister $i
done

echo "--- Cleaning up after Fusion"

for i in `vmrun list | grep -v "Total"`
do
echo "Stopping $i"
vmrun stop $i
sleep 10

echo "Deleting $i"
vmrun deleteVM $i
done

echo "--- Cleaning up after Packer"
rake clean

echo "--- Build $PLATFORM-$BENTO_PROVIDERS"
rake build_box[$PLATFORM]

echo "--- Upload Boxes"
rake upload_all

echo "--- Release Boxes"
rake release_all