Created
August 1, 2013 01:04
-
-
Save psftw/6127652 to your computer and use it in GitHub Desktop.
jenkins mass fix subversion credentials
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
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