Build owners on stable-2.13 with Buck
Change-Id: Iad3b872e2f0eda316f0ee7d58ae95e47625aaace
diff --git a/jenkins/gerrit-buck-bazel-plugin-owners.yaml b/jenkins/gerrit-buck-bazel-plugin-owners.yaml
index 5107abf..4ac68ae 100644
--- a/jenkins/gerrit-buck-bazel-plugin-owners.yaml
+++ b/jenkins/gerrit-buck-bazel-plugin-owners.yaml
@@ -10,16 +10,31 @@
artifacts: >
bazel-genfiles/plugins/{name}*/*{name}*.jar*
+- job-template:
+ name: 'plugin-owners-{branch}'
+ description: "Plugin owners stable-2.13 branch build with BUCK\n"
+ defaults: plugin-template
+ builders:
+ - shell:
+ !include-raw: gerrit-buck-build-owners-plugin.sh
+ publishers:
+ - archive:
+ artifacts: >
+ buck-out/gen/plugins/owners*/owners*.jar*,
+
- project:
name: owners
jobs:
- 'plugin-{name}-{branch}':
targets: 'plugins/owners/gerrit-owners:owners plugins/owners/gerrit-owners-autoassign:owners-autoassign'
branch:
- - stable-2.13
- stable-2.11
- stable-2.10
- 'plugin-owners-bazel-{branch}':
targets: 'plugins/owners plugins/owners-autoassign'
branch:
- master
+ - 'plugin-owners-{branch}':
+ targets: 'plugins/owners plugins/owners-autoassign'
+ branch:
+ - stable-2.13
diff --git a/jenkins/gerrit-buck-build-owners-plugin.sh b/jenkins/gerrit-buck-build-owners-plugin.sh
new file mode 100755
index 0000000..5e36bca
--- /dev/null
+++ b/jenkins/gerrit-buck-build-owners-plugin.sh
@@ -0,0 +1,29 @@
+#!/bin/bash -e
+
+# NOTE: All Gerrit plugins currently depend on, at a minimum
+# the bucklets repo, and most plugins don't build outside the
+# Gerrit tree, even with bucklets. As a result, we need to
+# graft the plugin onto the Gerrit repo. We do this by checking
+# out the proper version of Gerrit, removing the plugin if it
+# exists, then use git read-tree to put the plugin we're
+# building in place.
+git checkout -f gerrit/{branch}
+git read-tree -u --prefix=plugins/owners-plugin origin/{branch}
+cd plugins && ln -s owners-plugin/owners* . && cd ..
+cat plugins/owners-plugin/.buckconfig >> .buckconfig
+
+TARGETS=$(echo "{targets}" | sed -e 's/{{owners}}/owners/g')
+
+. set-java.sh 8
+
+buck build -v 3 $TARGETS
+
+for JAR in $(find buck-out/gen/plugins/ -regex '.*/owners\(-autoassign\)*\.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=buck-out/gen/plugins/{name}/$(basename $JAR)
+ [ "$JAR" -ef "$DEST_JAR" ] || mv $JAR $DEST_JAR
+ echo "$PLUGIN_VERSION" > buck-out/gen/plugins/{name}/$(basename $JAR-version)
+done