Build Gerrit v2.9 for older setups

There are still companies using Gerrit v2.9 in production
and they may need ad-hoc fixes, even if we are not going to
release any further official patch-release.

Change-Id: I89c3fe5ce5b9cea5f4d1736950934c7782e2ff94
diff --git a/jenkins/gerrit-buck-bazel-template.yaml b/jenkins/gerrit-buck-bazel-template.yaml
index 6209908..9cfca10 100644
--- a/jenkins/gerrit-buck-bazel-template.yaml
+++ b/jenkins/gerrit-buck-bazel-template.yaml
@@ -1,39 +1,5 @@
-- job-template:
-    name: 'Gerrit-{branch}'
-    project-type: flow
-    concurrent: false
-    needs-workspace: true
-    scm:
-      - git:
-         url: https://gerrit.googlesource.com/gerrit
-         branches:
-           - origin/{branch}
-         submodule:
-           recursive: true
-         skip-tag: true
-         basedir: gerrit
-    triggers:
-      - pollscm:
-          cron: 'H/10 * * * *'
-    properties:
-    properties:
-       - build-discarder:
-           days-to-keep: 256
-       - authorization:
-           anonymous:
-             - job-discover
-             - job-read
-             - job-extended-read
-    dsl: |
-      retries = 3
-      type = '{branch}' in ['stable-2.14','master'] ? 'bazel' : 'buck'
-      parallel (
-        {{ retry ( retries ) {{ build( "Gerrit-$type-{branch}" ) }} }}
-      )
-
-- job-template:
-    name: 'Gerrit-buck-{branch}'
-    description: "{name} {branch} branch build with Buck\n"
+- defaults:
+    name: gerrit-buck-defaults
     wrappers:
       - timeout:
           timeout: 90
@@ -84,6 +50,66 @@
          excludes: 'gerrit/buck-out/gen/plugins/core*/**/*.jar'
 
 - job-template:
+    name: 'Gerrit-{branch}'
+    project-type: flow
+    concurrent: false
+    needs-workspace: true
+    scm:
+      - git:
+         url: https://gerrit.googlesource.com/gerrit
+         branches:
+           - origin/{branch}
+         submodule:
+           recursive: true
+         skip-tag: true
+         basedir: gerrit
+    triggers:
+      - pollscm:
+          cron: 'H/10 * * * *'
+    properties:
+    properties:
+       - build-discarder:
+           days-to-keep: 256
+       - authorization:
+           anonymous:
+             - job-discover
+             - job-read
+             - job-extended-read
+    dsl: |
+      retries = 3
+      type = '{branch}' in ['stable-2.14','master'] ? 'bazel' : 'buck'
+      parallel (
+        {{ retry ( retries ) {{ build( "Gerrit-$type-{branch}" ) }} }}
+      )
+
+- job-template:
+    name: 'Gerrit-buck-{branch}'
+    description: "{name} {branch} branch build with Buck\n"
+    defaults: gerrit-buck-defaults
+
+- job:
+    name: Gerrit-buck-stable-2.9
+    description: "Gerrit 2.9 branch build with Buck\n"
+    defaults: gerrit-buck-defaults
+    scm:
+      - git:
+         url: https://gerrit.googlesource.com/gerrit
+         branches:
+           - origin/stable-2.9
+         submodule:
+           recursive: true
+         skip-tag: true
+         basedir: gerrit
+    triggers:
+      - pollscm:
+          cron: 'H/10 * * * *'
+    builders:
+      - shell:
+         !include-raw: gerrit-buck-build.sh
+      - shell:
+         !include-raw: gerrit-buck-test-2.9.sh
+
+- job-template:
     name: 'Gerrit-bazel-{branch}'
     description: "{name} {branch} branch build with Bazel\n"
     wrappers:
@@ -150,6 +176,7 @@
     jobs:
       - 'Gerrit-buck-{branch}'
 
+
 - project:
     name: Gerrit-bazel
     branch:
diff --git a/jenkins/gerrit-buck-test-2.9.sh b/jenkins/gerrit-buck-test-2.9.sh
new file mode 100644
index 0000000..4d70f98
--- /dev/null
+++ b/jenkins/gerrit-buck-test-2.9.sh
@@ -0,0 +1,10 @@
+#!/bin/bash -e
+
+cd gerrit
+
+SOURCE_LEVEL=$(grep "source_level" .buckconfig || echo "source_level=7")
+. set-java.sh $(echo $SOURCE_LEVEL | cut -d '=' -f 2 | tr -d '[[:space:]]')
+
+echo 'Test in default DB mode'
+echo '----------------------------------------------'
+buck test --all --exclude slow