3 # @License EPL-1.0 <http://spdx.org/licenses/EPL-1.0>
4 ##############################################################################
5 # Copyright (c) 2014 The Linux Foundation and others.
7 # All rights reserved. This program and the accompanying materials
8 # are made available under the terms of the Eclipse Public License v1.0
9 # which accompanies this distribution, and is available at
10 # http://www.eclipse.org/legal/epl-v10.html
13 # Thanh Ha (The Linux Foundation) - Initial implementation
14 ##############################################################################
21 def get_autoupdate_projects(jjb_dir, projects):
22 """Get list of projects that should be auto-updated."""
24 for project in projects:
25 template = os.path.join(jjb_dir, project, "%s.yaml" % project)
26 if os.path.isfile(template):
27 with open(template, 'r') as f:
28 first_line = f.readline()
29 if first_line.startswith("# REMOVE THIS LINE IF"):
30 project_list.append(project)
35 def update_templates(projects):
36 for project in projects:
38 # If project has customized variables
39 cfg_file = "jjb/%s/%s.cfg" % (project, project)
40 parameters = ["python scripts/jjb-init-project.py"]
41 parameters.append("-z") # Disable CFG auto-generation
42 if os.path.isfile(cfg_file):
43 stream = open(cfg_file, "r")
44 cfg = yaml.load(stream)
45 for k, v in cfg.items():
46 if k == "MVN_GOALS" and v is not None:
47 parameters.append("-g '%s'" % v)
48 elif k == "MVN_OPTS" and v is not None:
49 parameters.append("-o '%s'" % v)
50 elif k == "DEPENDENCIES" and v is not None:
51 parameters.append("-d '%s'" % v)
53 parameters.append(project)
54 cmd = " ".join(parameters)
58 os.system("python scripts/jjb-init-project.py -z %s" % project)
65 all_projects = [d for d in os.listdir(jjb_dir)
66 if os.path.isdir(os.path.join(jjb_dir, d))]
67 auto_update_projects = get_autoupdate_projects(jjb_dir, all_projects)
68 update_templates(auto_update_projects)