Add job for image-diff plugin

This also adds a job template to build UI-only plugins. These are
plugins only providing html and js files, but no jar file. The
default plugin build job was not usable for these artifacts, since
it artifact archiver was expecting a jar-file and would fail, if
it was missing.

The job expects a single html and a single js file with the plugin
name as the filename.

Change-Id: I4e80f1cb4604c3d0c842c8cacdbcc71906d31300
diff --git a/jenkins/gerrit-bazel-build-plugin.sh b/jenkins/gerrit-bazel-build-plugin.sh
index f867974..700fb0e 100644
--- a/jenkins/gerrit-bazel-build-plugin.sh
+++ b/jenkins/gerrit-bazel-build-plugin.sh
@@ -23,7 +23,10 @@
 bazelisk test --test_env DOCKER_HOST=$DOCKER_HOST //tools/bzl:always_pass_test plugins/{name}/...
 
 JAR="bazel-bin/plugins/{name}/{name}.jar"
-PLUGIN_VERSION=$(git describe  --always origin/{branch})
-echo -e "Implementation-Version: $PLUGIN_VERSION" > MANIFEST.MF
-jar ufm $JAR MANIFEST.MF && rm MANIFEST.MF
-echo "$PLUGIN_VERSION" > bazel-bin/plugins/{name}/$(basename $JAR-version)
+if test -f $JAR
+then
+  PLUGIN_VERSION=$(git describe  --always origin/{branch})
+  echo -e "Implementation-Version: $PLUGIN_VERSION" > MANIFEST.MF
+  jar ufm $JAR MANIFEST.MF && rm MANIFEST.MF
+  echo "$PLUGIN_VERSION" > bazel-bin/plugins/{name}/$(basename $JAR-version)
+fi
diff --git a/jenkins/gerrit-bazel-plugin-image-diff.yaml b/jenkins/gerrit-bazel-plugin-image-diff.yaml
new file mode 100644
index 0000000..fbe1bd1
--- /dev/null
+++ b/jenkins/gerrit-bazel-plugin-image-diff.yaml
@@ -0,0 +1,6 @@
+- project:
+    name: image-diff
+    jobs:
+      - 'ui-plugin-{name}-bazel-{branch}':
+          branch:
+            - master
diff --git a/jenkins/gerrit-bazel-plugin-template.yaml b/jenkins/gerrit-bazel-plugin-template.yaml
index f4478d7..7a56075 100644
--- a/jenkins/gerrit-bazel-plugin-template.yaml
+++ b/jenkins/gerrit-bazel-plugin-template.yaml
@@ -82,6 +82,40 @@
             bazel-bin/plugins/{name}/{name}.json
 
 - job-template:
+    name: 'ui-plugin-{name}-bazel-{branch}'
+    description: 'UI Plugin {name} {branch} branch build with Bazel'
+    defaults: plugin-template-bazel
+    node: bazel-debian
+    class: plugins
+    project-name: plugins%2F{name}
+    scm:
+      - git:
+          remotes:
+            - origin:
+                url: https://gerrit.googlesource.com/a/plugins/{name}
+                credentials-id: gerrit.googlesource.com
+            - gerrit:
+                url: https://gerrit.googlesource.com/a/gerrit
+                credentials-id: gerrit.googlesource.com
+          branches:
+            - origin/{branch}
+          submodule:
+            recursive: true
+            parent-credentials: true
+          skip-tag: true
+          do-not-fetch-tags: true
+    builders:
+      - set-git-credentials
+      - shell: !include-raw: gerrit-bazel-build-plugin.sh
+      - shell: !include-raw: gerrit-bazel-get-project-info.sh
+    publishers:
+      - archive:
+          artifacts: >
+            bazel-bin/plugins/{name}/{name}.js,
+            bazel-bin/plugins/{name}/{name}.html,
+            bazel-bin/plugins/{name}/{name}.json
+
+- job-template:
     name: 'plugin-{name}-bazel-{branch}-{gerrit-branch}'
     class: plugins
     node: bazel-debian
@@ -174,7 +208,7 @@
       - last-failure
       - last-duration
       - build-button
-    regex: '(plugin|module)-.+-{branch}'
+    regex: '(ui-plugin|plugin|module)-.+-{branch}'
 
 - project:
     name: 'plugin-views'