Created
December 14, 2011 13:39
-
-
Save yono/1476600 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
require 'open-uri' | |
require 'uri' | |
require 'rss' | |
def rss_url(fqdn, job_name, kind) | |
File.join(fqdn, 'job', job_name, kind) | |
end | |
def latest_title(rss_url) | |
rss = open(rss_url){ |file| RSS::Parser.parse(file.read) } | |
rss.items[0].title.to_s | |
end | |
if ARGV.size < 2 then | |
puts ARGV[0] | |
puts 'Usage: ruby compate_rss.rb JENKINS_URL JOB_NAME' | |
exit 1 | |
end | |
JENKINS_URL = ARGV[0] | |
JOB_NAME = ARGV[1] | |
RSS_ALL_URL = rss_url(JENKINS_URL, JOB_NAME, 'rssAll') | |
RSS_FAILED_URL = rss_url(JENKINS_URL, JOB_NAME, 'rssFailed') | |
latest_all = latest_title(RSS_ALL_URL) | |
latest_failed = latest_title(RSS_FAILED_URL) | |
puts latest_all | |
puts latest_failed | |
exit 1 if latest_all == latest_failed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment