Merge "jjb-init-project script support for branches"
authorAndrew Grimberg <agrimberg@linuxfoundation.org>
Mon, 19 Jan 2015 16:09:23 +0000 (16:09 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Mon, 19 Jan 2015 16:09:23 +0000 (16:09 +0000)
jjb/job.yaml.template
scripts/jjb-autoupdate-project.py
scripts/jjb-init-project.py

index 50b0f1c158d01d8559c5d02c64d1c55cf9d0f276..6a49b09cfd6ed61b45087688af83fb7e7ed56a76 100644 (file)
 
     # stream:    branch with - in place of / (eg. stable-helium)
     # branch:    branch (eg. stable/helium)
-    stream:
-        - master:
-            branch: 'master'
-        - stable-helium:
-            branch: 'stable/helium'
-
+    STREAMS
     project: 'PROJECT'
     jdk: 'openjdk7'
 
index ea1977940375301bc39606b1163062b11b51e98a..2569301b9aabc2f26c2cc27fd97cc76d244625dd 100644 (file)
@@ -43,7 +43,9 @@ def update_templates(projects):
             stream = open(cfg_file, "r")
             cfg = yaml.load(stream)
             for k, v in cfg.items():
-                if k == "MVN_GOALS" and v is not None:
+                if k == "BRANCHES" and v is not None:
+                    parameters.append("-b '%s'" % v)
+                elif k == "MVN_GOALS" and v is not None:
                     parameters.append("-g '%s'" % v)
                 elif k == "MVN_OPTS" and v is not None:
                     parameters.append("-o '%s'" % v)
index b6d3994d6394fb6ac3d756a9a032a3e6fab899dc..443bad0e0f938e89fa2097c9171dfe395fb00c73 100644 (file)
@@ -27,6 +27,7 @@ parser.add_argument("-d", "--dependencies",
                           "will trigger when a dependent project-merge job "
                           "is built successfully.\n\n"
                           "Example: aaa,controller,yangtools"))
+parser.add_argument("-b", "--branches", help="Git Branches to build")
 parser.add_argument("-g", "--mvn-goals", help="Maven Goals")
 parser.add_argument("-o", "--mvn-opts", help="Maven Options")
 parser.add_argument("-z", "--no-cfg", action="store_true",
@@ -36,6 +37,7 @@ args = parser.parse_args()
 project = args.project
 project_dir = os.path.join("jjb", project)
 project_file = os.path.join(project_dir, "%s.yaml" % project)
+branches = args.branches    # Defaults to "master,stable/helium" if not passed
 mvn_goals = args.mvn_goals  # Defaults to "clean install" if not passsed
 mvn_opts = args.mvn_opts    # Defaults to blank if not passed
 dependencies = args.dependencies
@@ -58,6 +60,19 @@ no_cfg = args.no_cfg
 make_cfg = False  # Set to true if we need to generate initial CFG file
 cfg_string = []
 
+if not branches:
+    branches = "master,stable/helium"
+else:
+    make_cfg = True
+    cfg_string.append("BRANCHES: %s" % branches)
+# Create YAML to list branches to create jobs for
+streams = "stream:\n"
+for branch in branches.split(","):
+    streams = streams + ("        - %s:\n"
+                         "            branch: '%s'\n" %
+                         (branch.replace('/', '-'),
+                          branch))
+
 if not mvn_goals:
     mvn_goals = ("clean install "
                  "-V "  # Show Maven / Java version before building
@@ -87,10 +102,12 @@ if not os.path.exists(project_dir):
     os.makedirs(project_dir)
 
 print("project: %s\n"
+      "branches: %s\n"
       "goals: %s\n"
       "options: %s\n"
       "dependencies: %s" %
       (project,
+       branches,
        mvn_goals,
        mvn_opts,
        dependencies))
@@ -110,6 +127,7 @@ with open(template_file, "r") as infile:
             if not re.match("\s*#", line):
                 line = re.sub("PROJECT", project, line)
                 line = re.sub("DISABLED", disabled, line)
+                line = re.sub("STREAMS", streams, line)
                 line = re.sub("MAVEN_GOALS", mvn_goals, line)
                 line = re.sub("MAVEN_OPTS", mvn_opts, line)
                 line = re.sub("DEPENDENCIES", dependent_jobs, line)