Merge "Add JJB CSIT compatible min job"
authorAndrew Grimberg <agrimberg@linuxfoundation.org>
Thu, 20 Nov 2014 17:33:59 +0000 (17:33 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Thu, 20 Nov 2014 17:33:59 +0000 (17:33 +0000)
README.md
jjb/job-custom.yaml.example [new file with mode: 0644]
jjb/job.yaml.example
jjb/job.yaml.template
jjb/releng-jobs.yaml
jjb/ttp/ttp.yaml
scripts/jjb-autoupdate-project.py [new file with mode: 0644]

index a4133ebda6a84f8da5cba642d7b6e184ce717e3d..2b5b9443c32d4cdef9c2414cf62b69a91e6a66e4 100644 (file)
--- a/README.md
+++ b/README.md
@@ -46,12 +46,20 @@ template which will create 6 jobs (verify, merge, and daily jobs for both
 master and stable/helium branch).
 
 Run the following steps from the repo root to create initial job config.
+This script will produce a file in jjb/<project>/<project>.yaml
+containing your project's base template.
 
     python scripts/jjb-init-project.py <project-name>
 
     # Example
     python scripts/jjb-init-project.py aaa
 
+    # Note: The optional options below require you to remove the 1st line
+    #       comment in the produced template file otherwise the auto
+    #       update script will overwrite the customization next time it
+    #       is run. See Auto Update Job Templates section below for more
+    #       details.
+    #
     # Optionally pass the following options:
     #
     # -g / --mvn-goals : With your job's Maven Goals necessary to build
@@ -65,3 +73,23 @@ Run the following steps from the repo root to create initial job config.
 If all your project requires is the basic verify, merge, and
 daily jobs then using the job.template should be all you need to
 configure for your jobs.
+
+=== Auto Update Job Templates
+
+The first line of the job YAML file produced by the script will contain
+the words # REMOVE THIS LINE IF... leaving this line will allow the
+releng/builder autoupdate script to maintain this file for your project
+should the base template ever change. It is a good idea to leave this
+line if you do not plan to create any complex jobs outside of the
+provided template.
+
+However if your project needs more control over your jobs or if you have
+any additional configuration outside of the standard configuration
+provided by the template then this line should be removed.
+
+It is also possible to take advantage of both the auto updater and creating
+your own jobs. To do this, create a YAML file in your project's sub-directory
+with any name other than <project>.yaml. The auto-update script will only
+search for files with the name <project>.yaml. The normal <project>.yaml
+file can then be left in tact with the "# REMOVE THIS LINE IF..." comment so
+it will be automatically updated.
diff --git a/jjb/job-custom.yaml.example b/jjb/job-custom.yaml.example
new file mode 100644 (file)
index 0000000..b786949
--- /dev/null
@@ -0,0 +1,176 @@
+# ODL Releng build templates
+- project:
+    name: controller
+    jobs:
+        - 'controller-verify-{stream}'
+        - 'controller-merge-{stream}'
+        - 'controller-daily-{stream}'
+
+    # stream:    branch with - in place of / (eg. stable-helium)
+    # branch:    branch (eg. stable/helium)
+    stream:
+        - master:
+            branch: 'master'
+        - stable-helium:
+            branch: 'stable/helium'
+
+
+# For the Job templates below replace instances of:
+# PROJECT with your project name (eg. controller)
+# MAVEN_GOALS with your maven goals to build
+# MAVEN_OPTS with your maven options to build
+
+- job-template:
+    name: 'controller-verify-{stream}'
+
+    # Job template for ODL verify jobs
+    #
+    # The purpose of this job template is to setup a ODL verify job
+    #
+    # Required Variables:
+    #     stream:    branch with - in place of / (eg. stable-helium)
+    #     branch:    branch (eg. stable/helium)
+
+    project-type: maven
+    node: dynamic_verify
+
+    logrotate:
+        daysToKeep: '{build-days-to-keep}'
+        numToKeep: '{build-num-to-keep}'
+        artifactDaysToKeep: '{build-artifact-days-to-keep}'
+        artifactNumToKeep: '{build-artifact-num-to-keep}'
+
+    parameters:
+        - gerrit-parameter:
+            branch: '{branch}'
+
+    scm:
+        - gerrit-trigger-scm:
+            credentials-id: '{ssh-credentials}'
+            scm-url: 'ssh://jenkins-releng@git.opendaylight.org:29418/controller.git'
+            refspec: '$GERRIT_REFSPEC'
+
+    wrappers:
+        - ssh-agent-credentials:
+            user: '{ssh-credentials}'
+
+    triggers:
+        - gerrit-trigger-patch-submitted:
+            name: 'controller'
+            branch: '{branch}'
+
+    maven:
+        maven-name: '{mvn32}'
+        root-pom: 'pom.xml'
+        goals: '-Dmaven.repo.local=$WORKSPACE/.m2repo -Dorg.ops4j.pax.url.mvn.localRepository=$WORKSPACE/.m2repo clean install'
+        maven-opts: '-Xmx2048m -XX:MaxPermSize=512m'
+        settings: '{controller-settings}'
+        global-settings: '{odl-global-settings}'
+
+    publishers:
+        - email-notification:
+            email-prefix: '[controller]'
+
+- job-template:
+    name: 'controller-merge-{stream}'
+
+    # 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
+
+    logrotate:
+        daysToKeep: '{build-days-to-keep}'
+        numToKeep: '{build-num-to-keep}'
+        artifactDaysToKeep: '{build-artifact-days-to-keep}'
+        artifactNumToKeep: '{build-artifact-num-to-keep}'
+
+    scm:
+        - gerrit-trigger-scm:
+            credentials-id: '{ssh-credentials}'
+            scm-url: 'ssh://jenkins-releng@git.opendaylight.org:29418/controller.git'
+            refspec: ''
+
+    wrappers:
+        - ssh-agent-credentials:
+            user: '{ssh-credentials}'
+
+    triggers:
+        - gerrit-trigger-patch-merged:
+            name: 'controller'
+            branch: '{branch}'
+
+    maven:
+        maven-name: '{mvn32}'
+        root-pom: 'pom.xml'
+        goals: '-Dmaven.repo.local=$WORKSPACE/.m2repo -Dorg.ops4j.pax.url.mvn.localRepository=$WORKSPACE/.m2repo clean install'
+        maven-opts: '-Xmx2048m -XX:MaxPermSize=512m'
+        settings: '{controller-settings}'
+        global-settings: '{odl-global-settings}'
+
+    publishers:
+        - email-notification:
+            email-prefix: '[controller]'
+        - maven-deploy:
+            id: ''
+            url: ''
+            unique-version: true
+            deploy-unstable: false
+
+- job-template:
+    name: 'controller-daily-{stream}'
+
+    # Job template for daily builders
+    #
+    # The purpose of this job template is to setup a daily/nightly
+    # builder and pushes to Sonar analysis.
+    #
+    # Required Variables:
+    #     stream:    branch with - in place of / (eg. stable-helium)
+    #     branch:    branch (eg. stable/helium)
+
+    project-type: maven
+    node: dynamic_verify
+
+    logrotate:
+        daysToKeep: '{build-days-to-keep}'
+        numToKeep: '{build-num-to-keep}'
+        artifactDaysToKeep: '{build-artifact-days-to-keep}'
+        artifactNumToKeep: '{build-artifact-num-to-keep}'
+
+    scm:
+        - git-scm:
+            credentials-id: '{ssh-credentials}'
+            scm-url: 'ssh://jenkins-releng@git.opendaylight.org:29418/controller.git'
+            refspec: ''
+            branch: '{branch}'
+
+    wrappers:
+        - ssh-agent-credentials:
+            user: '{ssh-credentials}'
+
+    triggers:
+        - timed: 'H H * * *'
+
+    maven:
+        maven-name: '{mvn32}'
+        root-pom: 'pom.xml'
+        goals: '-Dmaven.repo.local=$WORKSPACE/.m2repo -Dorg.ops4j.pax.url.mvn.localRepository=$WORKSPACE/.m2repo clean install'
+        maven-opts: '-Xmx2048m -XX:MaxPermSize=512m'
+        settings: '{controller-settings}'
+        global-settings: '{odl-global-settings}'
+
+    publishers:
+        - email-notification:
+            email-prefix: '[controller]'
+        - sonar:
+            branch: '{stream}'
+            language: 'java'
+            maven-opts: '-Xmx1024m'
index a7bf1d757ebd96a2a551819ffcea8476cb126a5f..87c9d13d7070cf5b74e7f070139e84d67a8ce837 100644 (file)
@@ -1,3 +1,7 @@
+# REMOVE THIS LINE IF YOU WANT TO CUSTOMIZE ANYTHING BELOW
+# Otherwise this file will be automatically overwritten by the template
+# autobuilder.
+
 # ODL Releng build templates
 - project:
     name: aaa
@@ -62,8 +66,8 @@
     maven:
         maven-name: '{mvn30}'
         root-pom: 'pom.xml'
-        goals: 'clean verify'
-        maven-opts: '-Xmx1024m'
+        goals: '-Dmaven.repo.local=$WORKSPACE/.m2repo -Dorg.ops4j.pax.url.mvn.localRepository=$WORKSPACE/.m2repo clean install'
+        maven-opts: '-Xmx1024m -XX:MaxPermSize=256m'
         settings: '{aaa-settings}'
         global-settings: '{odl-global-settings}'
 
     maven:
         maven-name: '{mvn30}'
         root-pom: 'pom.xml'
-        goals: 'clean verify'
-        maven-opts: '-Xmx1024m'
+        goals: '-Dmaven.repo.local=$WORKSPACE/.m2repo -Dorg.ops4j.pax.url.mvn.localRepository=$WORKSPACE/.m2repo clean install'
+        maven-opts: '-Xmx1024m -XX:MaxPermSize=256m'
         settings: '{aaa-settings}'
         global-settings: '{odl-global-settings}'
 
     maven:
         maven-name: '{mvn30}'
         root-pom: 'pom.xml'
-        goals: 'clean verify'
-        maven-opts: '-Xmx1024m'
+        goals: '-Dmaven.repo.local=$WORKSPACE/.m2repo -Dorg.ops4j.pax.url.mvn.localRepository=$WORKSPACE/.m2repo clean install'
+        maven-opts: '-Xmx1024m -XX:MaxPermSize=256m'
         settings: '{aaa-settings}'
         global-settings: '{odl-global-settings}'
 
index c77ad060dadef2b5f748d66d4e9ecab78629d90f..489f6a843cfc0181f62954cb51f668080ed96111 100644 (file)
@@ -1,3 +1,7 @@
+# REMOVE THIS LINE IF YOU WANT TO CUSTOMIZE ANYTHING BELOW
+# Otherwise this file will be automatically overwritten by the template
+# autobuilder.
+
 # ODL Releng build templates
 - project:
     name: PROJECT
index 5c5341cbc968d30ea57d083bd488463ea1a0ebad..963e9818ae4129723629590ce316d9d344405fbb 100644 (file)
             source /opt/virtualenv/jenkins-job-builder/bin/activate
             jenkins-jobs update jjb/
 
+            # Submit patches for any jobs that can be auto updated
+            python scripts/jjb-autoupdate-project.py
+            git commit -asm "Update automated project templates"
+            git push origin HEAD:refs/for/master
+
     publishers:
         - email-notification:
             email-prefix: '[releng]'
index 1b6aa8b204cc565cbcd146916f533292195f829b..eb72c16165459a8645559d80ca0ea02b2384721e 100644 (file)
@@ -1,3 +1,7 @@
+# REMOVE THIS LINE IF YOU WANT TO CUSTOMIZE ANYTHING BELOW
+# Otherwise this file will be automatically overwritten by the template
+# autobuilder.
+
 # ODL Releng build templates
 - project:
     name: ttp
diff --git a/scripts/jjb-autoupdate-project.py b/scripts/jjb-autoupdate-project.py
new file mode 100644 (file)
index 0000000..4b5e692
--- /dev/null
@@ -0,0 +1,30 @@
+#!/usr/bin/python
+
+import os
+
+def get_autoupdate_projects(jjb_dir, projects):
+    """Get list of projects that should be autoupdated"""
+    project_list = []
+    for project in projects:
+        template = os.path.join(jjb_dir, project, "{}.yaml".format(project))
+        if os.path.isfile(template):
+            with open(template, 'r') as f:
+                first_line = f.readline()
+            if first_line.startswith("# REMOVE THIS LINE IF"):
+                project_list.append(project)
+
+    return project_list
+
+def update_templates(projects):
+    for project in projects:
+        os.system("python scripts/jjb-init-project.py {}".format(project))
+
+##############
+# Code Start #
+##############
+
+jjb_dir = "jjb"
+all_projects = [ d for d in os.listdir(jjb_dir)
+                    if os.path.isdir(os.path.join(jjb_dir, d)) ]
+auto_update_projects = get_autoupdate_projects(jjb_dir, all_projects)
+update_templates(auto_update_projects)