Skip to content

Instantly share code, notes, and snippets.

@butaji
Last active August 29, 2015 14:10
Show Gist options
  • Save butaji/75ea9542905e238fa147 to your computer and use it in GitHub Desktop.
Save butaji/75ea9542905e238fa147 to your computer and use it in GitHub Desktop.
Generate changes by commits included in current TeamCity build
require 'net/http'
require 'json'
def get_json(uri)
url = URI.parse(uri)
req = Net::HTTP::Get.new(url, {'Accept' => "application/json"})
res = Net::HTTP.start(url.host, url.port) {|http|
http.request(req)
}
JSON.parse(res.body)
end
def main
prefix = ARGV[1]
if !ARGV[0]
raise "You must pass the build_id as argument"
return 1
end
build_id = ARGV[0]
changes = get_json("#{prefix}/httpAuth/app/rest/changes?build=id:#{build_id}")["change"]
if !changes
puts "nothing changed here"
return 0
end
for c in changes
change_id = c["id"]
change_det = get_json("#{prefix}/httpAuth/app/rest/changes/id:#{change_id}")
puts change_det["comment"]
end
end
main()
ruby changes.rb %teamcity.build.id% http://my_teamcity_server_url > changes.txt
@jincod
Copy link

jincod commented Nov 21, 2014

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