Skip to content

Instantly share code, notes, and snippets.

@grenzr
Created August 8, 2013 10:10
Show Gist options
  • Save grenzr/6183419 to your computer and use it in GitHub Desktop.
Save grenzr/6183419 to your computer and use it in GitHub Desktop.
Ultra simple Ruby script to find the latest version of a particular type of stemcell, passed in as first argument. (Requires xml-simple gem)
#!/usr/bin/env ruby
require 'open-uri'
require 'xmlsimple'
base_url = "http://bosh-jenkins-artifacts.s3.amazonaws.com"
#check_url = "?prefix=bosh-stemcell/openstack/bosh-stemcell"
check_url = "?prefix=#{ARGV[0]}"
doc = XmlSimple.xml_in(open("#{base_url}/#{check_url}").read)
latest_stemcell = doc['Contents'][doc['Contents'].length-1]['Key'][0]
print "#{base_url}/#{latest_stemcell}"
@grenzr
Copy link
Author

grenzr commented Aug 8, 2013

Example usage:

ruby -e "`curl -s https://gist.github.com/grenzr/6183419/raw/620b950c13c5225e4fea76a8d073cb496abcf728/new-stemcell-checker.rb`" bosh-stemcell/openstack/bosh-stemcell

Results in:

http://bosh-jenkins-artifacts.s3.amazonaws.com/bosh-stemcell/openstack/bosh-stemcell-openstack-kvm-877.tgz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment