Add integration job to common template 50/13750/4
authorThanh Ha <thanh.ha@linuxfoundation.org>
Fri, 19 Dec 2014 03:53:16 +0000 (22:53 -0500)
committerThanh Ha <thanh.ha@linuxfoundation.org>
Fri, 19 Dec 2014 04:50:41 +0000 (23:50 -0500)
This patch adds a new job type project-integration to the common job
template. It serves to be the single job to handle all integration jobs
existing on the master silo. This integration job is by default disabled
and unused.

Projects can pass a list of dependent projects in their project.cfg file for example:

DEPENDENCIES: aaa,controller,yangtools

This will flip the switch to enable the project-integration job and
cause a build to be triggered when any of the dependent jobs are built.

For email it will send an email with the project tags for ALL projects
listed in the dependencies list thusly notifying all dependent projects
of the build issue.

Change-Id: I8e06fb378dadb6d8b083b08cba366eb863efac76
Signed-off-by: Thanh Ha <thanh.ha@linuxfoundation.org>
README.md
jjb/job.yaml.template
scripts/jjb-autoupdate-project.py
scripts/jjb-init-project.py

index 11b11afc389327c8bce81cfc84bbb1b77b62e566..8a2e17775613402298db13e28587e3ef76f77e9f 100644 (file)
--- a/README.md
+++ b/README.md
@@ -102,8 +102,9 @@ following contents and tune as necessary. If there is a parameter you do
 NOT want to tune simply remove the parameter or comment out the line with a
 "#"" sign.
 
-    MVN_GOALS: -Dmaven.repo.local=$WORKSPACE/.m2repo -Dorg.ops4j.pax.url.mvn.localRepository=$WORKSPACE/.m2repo clean -DrepoBuild install javadoc:aggregate
+    MVN_GOALS: clean install javadoc:aggregate -DrepoBuild -Dmaven.repo.local=$WORKSPACE/.m2repo -Dorg.ops4j.pax.url.mvn.localRepository=$WORKSPACE/.m2repo
     MVN_OPTS: -Xmx1024m -XX:MaxPermSize=256m
+    DEPENDENCIES: aaa,controller,yangtools
 
 #### Advanced
 
index 7511f56df3f5df9ced86d3acfed3f3ff5c7831fb..8b3d1b32566d5c3f977b3c4f8db09d877016d92c 100644 (file)
@@ -9,6 +9,7 @@
         - 'PROJECT-verify-{stream}'
         - 'PROJECT-merge-{stream}'
         - 'PROJECT-daily-{stream}'
+        - 'PROJECT-integration-{stream}'
 
     # stream:    branch with - in place of / (eg. stable-helium)
     # branch:    branch (eg. stable/helium)
             branch: '{stream}'
             language: 'java'
             maven-opts: 'MAVEN_OPTS'
+
+- job-template:
+    name: 'PROJECT-integration-{stream}'
+    disabled: DISABLED
+
+    # Job template for ODL merge jobs
+    #
+    # The purpose of this job template is to setup a ODL merge job
+    # and deploy artifacts to Nexus.
+    #
+    # Required Variables:
+    #     stream:    branch with - in place of / (eg. stable-helium)
+    #     branch:    branch (eg. stable/helium)
+
+    project-type: maven
+    node: dynamic_merge
+    jdk: '{jdk}'
+
+    logrotate:
+        daysToKeep: '{build-days-to-keep}'
+        numToKeep: '{build-num-to-keep}'
+        artifactDaysToKeep: '{build-artifact-days-to-keep}'
+        artifactNumToKeep: '{build-artifact-num-to-keep}'
+
+    parameters:
+        - project-parameter:
+            project: '{project}'
+
+    scm:
+        - gerrit-trigger-scm:
+            credentials-id: '{ssh-credentials}'
+            refspec: ''
+            choosing-strategy: 'default'
+
+    wrappers:
+        - ssh-agent-credentials:
+            user: '{ssh-credentials}'
+
+    triggers:
+        - reverse:
+            jobs: 'DEPENDENCIES'
+            result: 'success'
+
+    maven:
+        maven-name: '{mvn32}'
+        root-pom: 'pom.xml'
+        goals: 'MAVEN_GOALS'
+        maven-opts: 'MAVEN_OPTS'
+        settings: '{PROJECT-settings}'
+        global-settings: '{odl-global-settings}'
+
+    publishers:
+        - email-notification:
+            email-prefix: 'EMAIL_PREFIX'
index 51701c90faacd87106c0c81fa718f02395e31bc5..68d255dde162f64d2dac71901e5df10d804dcbab 100644 (file)
@@ -46,6 +46,8 @@ def update_templates(projects):
                     parameters.append("-g '%s'" % v)
                 elif k == "MVN_OPTS" and v is not None:
                     parameters.append("-o '%s'" % v)
+                elif k == "DEPENDENCIES" and v is not None:
+                    parameters.append("-d '%s'" % v)
 
             parameters.append(project)
             cmd = " ".join(parameters)
index 13ffc358b492c93354bf7027daa1416ba30a5d04..db1402c725c12c6122ff4528a8441a7ed64f04f8 100644 (file)
@@ -19,6 +19,14 @@ import re
 
 parser = argparse.ArgumentParser()
 parser.add_argument("project", help="project")
+parser.add_argument("-d", "--dependencies",
+                    help=("Project dependencies\n\n"
+                          "A comma-seperated (no spaces) list of projects "
+                          "your project depends on. "
+                          "This is used to create an integration job that "
+                          "will trigger when a dependent project-merge job "
+                          "is built successfully.\n\n"
+                          "Example: aaa,controller,yangtools"))
 parser.add_argument("-g", "--mvn-goals", help="Maven Goals")
 parser.add_argument("-o", "--mvn-opts", help="Maven Options")
 args = parser.parse_args()
@@ -28,6 +36,10 @@ project_dir = os.path.join("jjb", project)
 project_file = os.path.join(project_dir, "%s.yaml" % project)
 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
+dependent_jobs = ""
+disabled = "true"   # Always disabled unless project has dependencies
+email_prefix = "[%s]" % project
 
 template_file = os.path.join("jjb", "job.yaml.template")
 
@@ -40,13 +52,25 @@ if not mvn_goals:
 if not mvn_opts:
     mvn_opts = "-Xmx1024m -XX:MaxPermSize=256m"
 
+if dependencies:
+    disabled = "false"
+    email_prefix = (email_prefix + " " +
+                    " ".join(['[%s]' % d for d in dependencies.split(",")]))
+    dependent_jobs = ",".join(
+        ['%s-merge' % d for d in dependencies.split(",")])
+
 # Create project directory if it doesn't exist
 if not os.path.exists(project_dir):
     os.makedirs(project_dir)
 
-print("project: %s\ngoals: %s\noptions: %s" % (project,
-                                               mvn_goals,
-                                               mvn_opts))
+print("project: %s\n"
+      "goals: %s\n"
+      "options: %s\n"
+      "dependencies: %s" %
+      (project,
+       mvn_goals,
+       mvn_opts,
+       dependencies))
 
 # Create initial project YAML file
 with open(template_file, "r") as infile:
@@ -54,8 +78,9 @@ with open(template_file, "r") as infile:
         for line in infile:
             if not re.match("\s*#", line):
                 line = re.sub("PROJECT", project, line)
-            if not re.match("\s*#", line):
+                line = re.sub("DISABLED", disabled, line)
                 line = re.sub("MAVEN_GOALS", mvn_goals, line)
-            if not re.match("\s*#", line):
                 line = re.sub("MAVEN_OPTS", mvn_opts, line)
+                line = re.sub("DEPENDENCIES", dependent_jobs, line)
+                line = re.sub("EMAIL_PREFIX", email_prefix, line)
             outfile.write(line)