Make Merge and Verify job triggers overrideable 35/5835/2
authorThanh Ha <thanh.ha@linuxfoundation.org>
Thu, 10 Aug 2017 20:32:01 +0000 (16:32 -0400)
committerThanh Ha <thanh.ha@linuxfoundation.org>
Thu, 10 Aug 2017 20:49:00 +0000 (16:49 -0400)
This makes merge and verify jobs that use Gerrit Trigger be able to
override the default trigger defined by the job. This is useful in cases
where a project may have topic branches that they do not wish to
configure their build rules differently. For example in OpenDaylight the
NetVirt project has a need for topic branches but they  don't want to
run testing against every patch submission in the topic branches and
would prefer to run them manually. This patch would allow them to
reconfigure the triggers in that case for the topic branch.

Based on a POC from:
https://git.opendaylight.org/gerrit/61385

Change-Id: Idf1d301572bb33f5b540f1011658cdd3f3fc69f5
Signed-off-by: Thanh Ha <thanh.ha@linuxfoundation.org>
README.md
jjb/lf-ci-jobs.yaml
jjb/lf-python-jobs.yaml

index bc6fcc7..c1522bc 100644 (file)
--- a/README.md
+++ b/README.md
@@ -271,6 +271,17 @@ In this method a job can define a globstar for example `**/*.log` which then
 causes the archive script to do a globstar search for that pattern and archives
 any files it finds matching.
 
+## Overriding merge and verify triggers
+
+The default trigger conditions for Merge and Verify job types are overrideable
+in a project configuration by overriding the following variables:
+
+- gerrit_merge_triggers
+- gerrit_verify_triggers
+
+These variables take a list of trigger-on values as defined in JJB docs here:
+<https://docs.openstack.org/infra/jenkins-job-builder/triggers.html#triggers.gerrit>
+
 ## Appendix
 
 ### ShellCheck
index 40e7185..c130f26 100644 (file)
 
     git-url: '$GIT_URL/$GERRIT_PROJECT'
 
+    gerrit_merge_triggers:
+      - change-merged-event
+      - comment-added-contains-event:
+          comment-contains-value: remerge$
+
     #####################
     # Job Configuration #
     #####################
     triggers:
       - gerrit:
           server-name: '{gerrit-server-name}'
-          trigger-on:
-            - change-merged-event
-            - comment-added-contains-event:
-                comment-contains-value: remerge$
+          trigger-on: '{obj:gerrit_merge_triggers}'
           projects:
             - project-compare-type: ANT
               project-pattern: '{project}'
 
     git-url: '$GIT_URL/$GERRIT_PROJECT'
 
+    gerrit_verify_triggers:
+      - patchset-created-event:
+          exclude-drafts: false
+          exclude-trivial-rebase: false
+          exclude-no-code-change: false
+      - draft-published-event
+      - comment-added-contains-event:
+          comment-contains-value: recheck$
+
     #####################
     # Job Configuration #
     #####################
     triggers:
       - gerrit:
           server-name: '{gerrit-server-name}'
-          trigger-on:
-            - patchset-created-event:
-                exclude-drafts: false
-                exclude-trivial-rebase: false
-                exclude-no-code-change: false
-            - draft-published-event
-            - comment-added-contains-event:
-                comment-contains-value: recheck$
+          trigger-on: '{obj:gerrit_verify_triggers}'
           projects:
             - project-compare-type: ANT
               project-pattern: '{project}'
 
     git-url: '$GIT_URL/$GERRIT_PROJECT'
 
+    gerrit_merge_triggers:
+      - change-merged-event
+      - comment-added-contains-event:
+          comment-contains-value: remerge$
+
     #####################
     # Job Configuration #
     #####################
       - timed: '00 10 1 * *'
       - gerrit:
           server-name: '{gerrit-server-name}'
-          trigger-on:
-            - change-merged-event
-            - comment-added-contains-event:
-                comment-contains-value: remerge$
+          trigger-on: '{obj:gerrit_merge_triggers}'
           projects:
             - project-compare-type: ANT
               project-pattern: '{project}'
     build-timeout: 10
     git-url: '$GIT_URL/$GERRIT_PROJECT'
 
+    gerrit_verify_triggers:
+      - patchset-created-event:
+          exclude-drafts: false
+          exclude-trivial-rebase: false
+          exclude-no-code-change: false
+      - draft-published-event
+      - comment-added-contains-event:
+          comment-contains-value: recheck$
+
     #####################
     # Job Configuration #
     #####################
     triggers:
       - gerrit:
           server-name: '{gerrit-server-name}'
-          trigger-on:
-            - patchset-created-event:
-                exclude-drafts: false
-                exclude-trivial-rebase: false
-                exclude-no-code-change: false
-            - draft-published-event
-            - comment-added-contains-event:
-                comment-contains-value: recheck$
+          trigger-on: '{obj:gerrit_verify_triggers}'
           projects:
             - project-compare-type: ANT
               project-pattern: '{project}'
index e66f522..99c0661 100644 (file)
     id: gerrit-tox-verify
     <<: *lf_tox_verify
 
+    ######################
+    # Default parameters #
+    ######################
+
+    gerrit_verify_triggers:
+      - patchset-created-event:
+          exclude-drafts: false
+          exclude-trivial-rebase: false
+          exclude-no-code-change: false
+      - draft-published-event
+      - comment-added-contains-event:
+          comment-contains-value: recheck$
+
+    #####################
+    # Job Configuration #
+    #####################
+
     scm:
       - lf-infra-gerrit-scm:
           jenkins-ssh-credential: '{jenkins-ssh-credential}'
     triggers:
       - gerrit:
           server-name: '{gerrit-server-name}'
-          trigger-on:
-            - patchset-created-event:
-                exclude-drafts: false
-                exclude-trivial-rebase: false
-                exclude-no-code-change: false
-            - draft-published-event
-            - comment-added-contains-event:
-                comment-contains-value: recheck$
+          trigger-on: '{obj:gerrit_verify_triggers}'
           projects:
             - project-compare-type: ANT
               project-pattern: '{project}'