Changeset 6071 in /cluster/svnroot
- Timestamp:
- Aug 12, 2018 2:24:40 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
bccd-ng/branches/skylar/bccd-3.4.0-build_ng/bin/gen_jenkins_job_xml
r6067 r6071 5 5 import argparse 6 6 import glob 7 import urllib3 7 8 import os 9 10 from bs4 import BeautifulSoup 8 11 9 12 def get_args(): 10 13 parser = argparse.ArgumentParser() 11 14 12 15 parser.add_argument('--svn_url', help='URL to SVN branch or tag',required=True,) 13 parser.add_argument('--stage', help='Branch name (i.e. skylar) or simply "tag" for production build',required=True,) 16 parser.add_argument('--version', help='BCCD version to build',required=True,) 17 parser.add_argument('--user', help='Developer user name to include in version tag',required=False,) 14 18 parser.add_argument('--config_dir', help='Directory of Jenkins job configs',required=True,) 15 19 parser.add_argument('--job_dir', help='Jenkins job directory path',required=True,) … … 17 21 return parser.parse_args() 18 22 19 def get_config_files(config_dir,stage): 20 """Reads template job files from config_dir, and then returns a list of dictionaries where the key is the input filename""" 21 """and the value is the output file name (either with the stage name inserted after BCCD-, or kept the same in""" 22 """the case of the tag stage).""" 23 return map(lambda f: {os.path.basename(f),os.path.basename(f) if stage=='tag' else os.path.basename(f).replace('BCCD-','BCCD-{}-'.format(stage),1)}, 24 glob.glob(os.path.join(config_dir,'*.xml'))) 23 def get_jenkins_project_configs(url): 24 """Takes in a URL for the Jenkins config directory in SVN, and returns a dictionary of project_name,config_xml_data""" 25 """Requires each sub-directory of the Jenkins config directory to have a config.xml file""" 26 http = urllib3.PoolManager() 27 return {k:v.data for k,v in 28 {u.strip("/"): http.request('GET', url + '/' + u + '/config.xml') 29 for u in map(lambda x: x['href'], 30 filter(lambda h: 31 h['href'] != '../', 32 BeautifulSoup(http.request('GET',url).data,'html.parser',).find_all('a',href=True) 33 ) 34 ) 35 }.items() if v.status == 200 36 } 25 37 26 38 def main(): 27 39 args = get_args() 28 40 29 print(list(get_config_files(config_dir=args.config_dir,stage=args.stage))) 41 print(get_jenkins_project_configs(args.svn_url)) 42 43 #print(list(get_config_files( 44 # config_dir=args.config_dir, 45 # version_string='{0}{1}'.format(args.version,'_' + args.user if args.user else '') 46 # ))) 30 47 31 48 if __name__ == '__main__':
Note: See TracChangeset
for help on using the changeset viewer.