9 parser = argparse.ArgumentParser()
10 parser.add_argument("project", help="project")
11 parser.add_argument("-c", "--conf", help="Config file")
12 parser.add_argument("-d", "--dependencies",
13 help=("Project dependencies\n\n"
14 "A comma-seperated (no spaces) list of projects "
15 "your project depends on. "
16 "This is used to create an integration job that "
17 "will trigger when a dependent project-merge "
18 "job is built successfully.\n\n"
19 "Example: aaa,controller,yangtools"))
20 parser.add_argument("-t", "--templates", help="Job templates to use")
21 parser.add_argument("-s", "--streams",
22 help="Release streams to fill with default options")
23 parser.add_argument("-p", "--pom", help="Path to pom.xml to use in Maven "
24 "build (Default: pom.xml")
25 parser.add_argument("-g", "--mvn-goals", help="Maven Goals")
26 parser.add_argument("-o", "--mvn-opts", help="Maven Options")
27 parser.add_argument("-a", "--archive-artifacts",
28 help="Comma-seperated list of patterns of artifacts "
29 "to archive on build completion. "
30 "See: http://ant.apache.org/manual/Types/fileset.html") # noqa
31 return parser.parse_args()
34 STREAM_DEFAULTS = collections.OrderedDict([
35 ("boron", {"branch": "master", "jdks": "openjdk8"}),
36 ("beryllium", {"branch": "stable/beryllium", "jdks": "openjdk8"}),
37 ("stable-lithium", {"branch": "stable/lithium", "jdks": "openjdk7"}),
38 ("stable-helium", {"branch": "stable/helium", "jdks": "openjdk7"}),
42 def create_template_config(project_dir, args):
46 cfg_data["JOB_TEMPLATES"] = args.templates
50 for stream in args.streams.split(","):
51 stream_list.append({stream: STREAM_DEFAULTS[stream]})
52 cfg_data["STREAMS"] = stream_list
55 cfg_data["POM"] = args.pom
58 cfg_data["MAVEN_GOALS"] = args.mvn_goals
61 cfg_data["MAVEN_OPTS"] = args.mvn_opts
64 cfg_data["DEPENDENCIES"] = args.dependencies
66 if args.archive_artifacts:
67 cfg_data["ARCHIVE"] = args.archive_artifacts
70 # Create project directory if it doesn't exist
71 if not os.path.exists(project_dir):
72 os.makedirs(project_dir)
74 print("Creating %s.cfg file" % args.project)
75 cfg_file = os.path.join(project_dir, "%s.cfg" % args.project)
77 with open(cfg_file, "w") as outstream:
78 outstream.write(yaml.dump(cfg_data, default_flow_style=False))
82 """Represents a Gerrit Project
85 path(str): The full Gerrit path to a project
86 meta_project(str): The top-level project name in Gerrit
87 project(str): The subproject name or project shortname
90 def __init__(self, project):
92 self.meta_project = None
93 self.project = project
95 if project.find('/') >= 0:
96 s = project.rsplit('/', 1)
97 self.meta_project = s[0]