-# The below 2 variables are used to determine if we should generate a CFG file
-# for a project automatically.
-#
-# no_cfg - is a commandline parameter that can be used by scripts such as the
-# jjb-autoupdate-project script to explicitly disable generating CFG
-# files.
-# make_cfg - is a internal variable used to decide if we should try to
-# auto generate the CFG file for a project based on optional
-# variables passed by the user on the commandline.
-no_cfg = args.no_cfg
-make_cfg = False # Set to true if we need to generate initial CFG file
-cfg_string = []
-
-if not mvn_goals:
+if not args.conf:
+ jjblib.create_template_config(project_dir, args)
+ project_conf = os.path.join(project_dir, "%s.cfg" % args.project)
+else:
+ project_conf = args.conf
+
+cfg = dict() # Needed to skip missing project.cfg files
+if os.path.isfile(project_conf):
+ stream = open(project_conf, "r")
+ cfg = yaml.load(stream)
+
+####################
+# Handle Templates #
+####################
+if cfg.get("JOB_TEMPLATES"):
+ templates = cfg.get("JOB_TEMPLATES")
+else:
+ templates = (
+ "verify,merge,periodic,distribution,distribution-check,integration,"
+ "sonar")
+templates += ",clm" # ensure we always create a clm job for all projects
+templates += ",validate-autorelease" # Autorelease validate template
+
+##################
+# Handle Streams #
+##################
+streams = OrderedDict()
+if cfg.get("STREAMS"): # this is a list of single-key dicts
+ for stream_dict in cfg.get("STREAMS"):
+ streams.update(stream_dict)
+else:
+ streams = {"boron": jjblib.STREAM_DEFAULTS["boron"]}
+
+first_stream = next(iter(streams)) # Keep master branch at top.
+sonar_branch = streams[first_stream]["branch"]
+# Create YAML to list branches to create jobs for
+str_streams = "stream:\n"
+for stream, options in streams.items():
+ str_streams += (" - %s:\n"
+ " branch: '%s'\n" %
+ (stream, options["branch"]))
+ str_streams += " jdk: %s\n" % options["jdks"].split(',')[0].strip() # noqa
+ str_streams += " jdks:\n"
+ for jdk in options["jdks"].split(","):
+ str_streams += " - %s\n" % jdk.strip()
+
+ # Disable autorelease validate job unless project is participating
+ # in autorelease, JJB does not allow flipping a boolean so we have to
+ # flip it here via not operator since the JJB configuration for disabling
+ # a Jenkins Job is "disabled: bool".
+ str_streams += " disable_autorelease: %s\n" % (not options.get(
+ "autorelease", False))
+
+ # Disable the distribution-check job unless project enables it
+ str_streams += " disable_distribution_check: %s\n" % (
+ not options.get("distribution-check", True))
+
+###############
+# Handle JDKS #
+###############
+if cfg.get('JDKS'):
+ jdks = cfg.get('JDKS')
+else:
+ jdks = "openjdk7"
+use_jdks = ""
+for jdk in jdks.split(","):
+ use_jdks += " - %s\n" % jdk
+
+##############
+# Handle POM #
+##############
+if cfg.get('POM'):
+ pom = cfg.get('POM')
+else:
+ pom = "pom.xml"
+
+####################
+# Handle MVN_GOALS #
+####################
+if cfg.get('MVN_GOALS'):
+ mvn_goals = cfg.get('MVN_GOALS')
+else: