Build the examples plugin
Build the examples plugin for Gerrit 2.14, 2.15, 2.16, 3.0, 3.1, and
master.
Use a custom build script since this plugin builds standalone and
expects to run within the plugin dir.
Change-Id: I92234796eba786ce178ee27ee0ef4bafef94ab2a
diff --git a/jenkins/gerrit-bazel-build-examples-plugin.sh b/jenkins/gerrit-bazel-build-examples-plugin.sh
new file mode 100644
index 0000000..2dd4588
--- /dev/null
+++ b/jenkins/gerrit-bazel-build-examples-plugin.sh
@@ -0,0 +1,39 @@
+#!/bin/bash -e
+
+PLUGIN_PATH=plugins/{name}
+
+git checkout -fb {branch} gerrit/{branch}
+git submodule update --init
+rm -rf "$PLUGIN_PATH"
+git read-tree -u --prefix=$PLUGIN_PATH origin/{branch}
+
+if [ -f "$PLUGIN_PATH"/external_plugin_deps.bzl ]
+then
+ cp -f "$PLUGIN_PATH"/external_plugin_deps.bzl plugins/
+fi
+
+TARGETS=$(echo "{targets}" | sed -e 's/{{name}}/{name}/g')
+
+. set-java.sh 8
+
+java -fullversion
+bazelisk version
+
+pushd "$PLUGIN_PATH"
+bazelisk build --spawn_strategy=standalone --genrule_strategy=standalone all
+
+EXAMPLES=( $(find * -depth 0 -type d -name 'example-*') )
+popd
+
+for EXAMPLE in "${EXAMPLES[@]}"
+do
+ for JAR in $(find "$PLUGIN_PATH"/bazel-bin/"$EXAMPLE" -name "$EXAMPLE".jar)
+ do
+ PLUGIN_VERSION=$(git describe --always origin/{branch})
+ echo -e "Implementation-Version: $PLUGIN_VERSION" > MANIFEST.MF
+ jar ufm $JAR MANIFEST.MF && rm MANIFEST.MF
+ DEST_JAR=bazel-bin/"$PLUGIN_PATH"/$(basename $JAR)
+ [ "$JAR" -ef "$DEST_JAR" ] || mv $JAR $DEST_JAR
+ echo "$PLUGIN_VERSION" > bazel-bin/"$PLUGIN_PATH"/$(basename $JAR-version)
+ done
+done
diff --git a/jenkins/gerrit-bazel-plugin-examples.yaml b/jenkins/gerrit-bazel-plugin-examples.yaml
new file mode 100644
index 0000000..e3d27ee
--- /dev/null
+++ b/jenkins/gerrit-bazel-plugin-examples.yaml
@@ -0,0 +1,35 @@
+- job-template:
+ name: 'plugin-examples-bazel-{branch}'
+ description: 'Plugin examples {branch} branch build with Bazel'
+ defaults: plugin-template-bazel
+ scm:
+ - git:
+ remotes:
+ - origin:
+ url: https://gerrit.googlesource.com/plugins/{name}
+ - gerrit:
+ url: https://gerrit.googlesource.com/gerrit
+ branches:
+ - origin/{branch}
+ submodule:
+ recursive: true
+ skip-tag: true
+ builders:
+ - shell: !include-raw: gerrit-bazel-build-examples-plugin.sh
+ publishers:
+ - archive:
+ artifacts: >
+ bazel-bin/all.zip
+
+- project:
+ name: examples
+ jobs:
+ - 'plugin-{name}-bazel-{branch}':
+ targets: 'all'
+ branch:
+ - master
+ - stable-3.1
+ - stable-3.0
+ - stable-2.16
+ - stable-2.15
+ - stable-2.14