Skip to content

Instantly share code, notes, and snippets.

@psftw
Created August 1, 2013 01:04
Show Gist options
  • Save psftw/6127652 to your computer and use it in GitHub Desktop.
Save psftw/6127652 to your computer and use it in GitHub Desktop.
jenkins mass fix subversion credentials
from glob import glob
import xml.etree.ElementTree as ET
credentials = {"example.com": ("username", "jumbledpassword") }
for cfile in glob("jobs/*/subversion.credentials"):
tree = ET.parse(cfile)
entries = tree.findall('//entry')
for entry in entries:
url = entry.find('string')
user = entry.find('.//userName')
passwd = entry.find('.//password')
if user is None and passwd is None:
print "refers to global: %s" % cfile
continue
if not any(x in url.text for x in credentials):
ET.dump(entry)
continue
for cred in credentials:
if cred in url.text:
user.text, passwd.text = credentials[cred]
tree.write(cfile)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment