Generate different jobs for Buck and Bazel

A unique build with Buck *and* Bazel makes difficult
to browse the logs and get a sense on where is the
problem: build or code?

Much better to isolate in different builds
and then build up a flow on top of it to
aggregate the results.

Change-Id: Iced9fff5577d11ba8e05eee96920b9ebb9bebbb1
diff --git a/jenkins/gerrit-buck-bazel-template.yaml b/jenkins/gerrit-buck-bazel-template.yaml
index 9835f41..99a3ee4 100644
--- a/jenkins/gerrit-buck-bazel-template.yaml
+++ b/jenkins/gerrit-buck-bazel-template.yaml
@@ -1,6 +1,38 @@
 - job-template:
-    name: '{name}-{branch}'
-    description: "{name} {branch} branch build with BUCK\n"
+    name: 'Gerrit-{branch}'
+    project-type: flow
+    concurrent: false
+    needs-workspace: true
+    logrotate:
+      numToKeep: 256
+    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:
+       - authorization:
+           anonymous:
+             - job-discover
+             - job-read
+             - job-extended-read
+    dsl: |
+      retries = 3
+      parallel (
+        {{ retry ( retries ) {{ build( "Gerrit-{branch}-buck" ) }} }},
+        {{ retry ( retries ) {{ build( "Gerrit-{branch}-bazel" ) }} }}
+      )
+
+- job-template:
+    name: 'Gerrit-{branch}-buck'
+    description: "{name} {branch} branch build with Buck\n"
     wrappers:
       - timeout:
           timeout: 90
@@ -37,19 +69,12 @@
            recursive: true
          skip-tag: true
          basedir: gerrit
-    triggers:
-      - pollscm:
-          cron: 'H/10 * * * *'
 
     builders:
       - shell:
          !include-raw-escape: gerrit-buck-build.sh
       - shell:
          !include-raw-escape: gerrit-buck-test.sh
-      - shell:
-         !include-raw-escape: gerrit-bazel-build.sh
-      - shell:
-         !include-raw-escape: gerrit-bazel-test.sh
     publishers:
       - archive:
          artifacts: >
@@ -58,8 +83,62 @@
 
          excludes: 'gerrit/buck-out/gen/plugins/core*/**/*.jar'
 
+- job-template:
+    name: 'Gerrit-{branch}-bazel'
+    description: "{name} {branch} branch build with Bazel\n"
+    wrappers:
+      - timeout:
+          timeout: 90
+          type: absolute
+          fail: false
+      - timestamps
+      - xvfb:
+          installation-name: Xvfb
+          auto-display-name: true
+          parallel-build: false
+          timeout: 10
+          screen: 1024x768x16
+          display-name-offset: 100
+          additional-options: -fbdir /tmp
+          debug: true
+          shutdown-with-build: false
+      - raw:
+          xml: <jenkins.plugins.logstash.LogstashBuildWrapper plugin="logstash@1.2.0"/>
+    logrotate:
+      numToKeep: 20
+      artifactNumToKeep: 20
+    properties:
+       - authorization:
+           anonymous:
+             - job-discover
+             - job-read
+             - job-extended-read
+    scm:
+      - git:
+         url: https://gerrit.googlesource.com/gerrit
+         branches:
+           - origin/{branch}
+         submodule:
+           recursive: true
+         skip-tag: true
+         basedir: gerrit
+
+    builders:
+      - shell:
+         !include-raw-escape: gerrit-bazel-build.sh
+      - shell:
+         !include-raw-escape: gerrit-bazel-test.sh
+    publishers:
+      - archive:
+         artifacts: >
+           gerrit/bazel-bin/*.war,gerrit/bazel-genfiles/plugins/*/*.jar,
+           gerrit/bazel-genfiles/*api/*api.jar,
+           gerrit/bazel-genfiles/gerrit-acceptance-framework/*.jar
+
+         excludes: 'gerrit/bazel-genfiles/plugins/core*/**/*.jar'
+
 - project:
-    name: Gerrit
+    name: Gerrit-buck
     branch:
       - master
       - stable-2.13
@@ -67,4 +146,18 @@
       - stable-2.11
       - stable-2.10
     jobs:
-      - '{name}-{branch}'
+      - 'Gerrit-{branch}-buck'
+
+- project:
+    name: Gerrit-bazel
+    branch:
+      - master
+    jobs:
+      - 'Gerrit-{branch}-bazel'
+
+- project:
+    name: Gerrit-build-flow
+    branch:
+      - master
+    jobs:
+      - 'Gerrit-{branch}'