Created
August 8, 2013 10:10
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example usage:
Results in: