Skip to content

Instantly share code, notes, and snippets.

@eiyaya
Last active December 10, 2015 19:29
Show Gist options
  • Save eiyaya/4481959 to your computer and use it in GitHub Desktop.
Save eiyaya/4481959 to your computer and use it in GitHub Desktop.
get info from jenkis
import json,sys,os
import urllib2
url = 'http://10.6.198.114/job/BaseIM_basicim4ml/lastBuild/api/json'
try:
u = urllib2.urlopen(url).read()
except:
exit(0)
try:
baseim = json.loads(u)
baseim_revision = baseim["changeSet"]['revisions'][0]['revision']
print baseim_revision
revision_with_baseim = ">%s-BASEIM-%s<" % (os.environ['SVN_REVISION'],baseim_revision)
new_rules = []
with open("custom_rules.xml") as f:
for line in f:
new_rules.append(line.replace('>${env.SVN_REVISION}<',revision_with_baseim))
print "".join(new_rules)
with open("custom_rules.xml","w") as f:
f.write("".join(new_rules))
except:
exit(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment