From 99b16921307e7eef1aa4e08745b7af968a1f7435 Mon Sep 17 00:00:00 2001
From: Khai Do <zaro0508@gmail.com>
Date: Thu, 16 Jun 2016 14:31:18 -0700
Subject: [PATCH] Add a build for the gerrit its-storyboard plugin

The its-storyboard plugin will allows us to integrate gerrit with
storyboard.  Add a build for the gerrit its-storyboard plugin[1].
Building this plugin also requires building the its-base plugin[2]
because the its-storyboard depends on its-base.  Refactored the build
job to build a parent project if it's defined in the project yaml.

[1] https://gerrit.googlesource.com/plugins/its-storyboard
[2] https://gerrit.googlesource.com/plugins/its-base

Change-Id: I7b8461bb47ba902158531a64ddf88a9bb2b03312
---
 jenkins/jobs/gerrit-plugin-jobs.yaml |  7 +++++++
 jenkins/jobs/projects.yaml           | 11 +++++++++++
 2 files changed, 18 insertions(+)

diff --git a/jenkins/jobs/gerrit-plugin-jobs.yaml b/jenkins/jobs/gerrit-plugin-jobs.yaml
index 7a48257fed..94106d57d4 100644
--- a/jenkins/jobs/gerrit-plugin-jobs.yaml
+++ b/jenkins/jobs/gerrit-plugin-jobs.yaml
@@ -16,12 +16,19 @@
           export PATH=`pwd`/buck/bin:$PATH
           rm -rf gerrit
           git clone -b {gerrit-branch} {gerrit-project}
+          PLUGIN_PARENT_PROJECT={plugin-parent-project}
+          if [ -n "$PLUGIN_PARENT_PROJECT" ]; then
+            git clone -b {gerrit-branch} {plugin-parent-project} gerrit/plugins/{plugin-parent-name}
+          fi
           git clone -b {plugin-branch} {plugin-project} gerrit/plugins/{plugin-name}
           cd gerrit/plugins/{plugin-name}
           /usr/local/jenkins/slave_scripts/version-properties.sh
           source version.properties
           cd $WORKSPACE/gerrit
           buck clean
+          if [ -n "$PLUGIN_PARENT_PROJECT" ]; then
+            buck build plugins/{plugin-parent-name}:{plugin-parent-name}
+          fi
           buck build plugins/{plugin-name}:{plugin-name}
           cp ./buck-out/gen/plugins/{plugin-name}/{plugin-name}.jar ./buck-out/gen/plugins/{plugin-name}/{plugin-name}-$PROJECT_VER.jar
 
diff --git a/jenkins/jobs/projects.yaml b/jenkins/jobs/projects.yaml
index 99e6e7e129..bd02353242 100644
--- a/jenkins/jobs/projects.yaml
+++ b/jenkins/jobs/projects.yaml
@@ -1992,6 +1992,8 @@
     name: gerrit
     tarball-site: tarballs.openstack.org
     gerrit-project: 'https://git.openstack.org/openstack-infra/gerrit'
+    plugin-parent-name: ''
+    plugin-parent-project: ''
 
     jobs:
       - '{plugin-name}-gerrit-plugin-{plugin-branch}':
@@ -2009,6 +2011,15 @@
           plugin-name: 'importer'
           plugin-project: 'https://gerrit.googlesource.com/plugins/{plugin-name}'
           plugin-branch: 'stable-2.11'
+      # its plugins depend on a parent plugin. We need to build parent
+      # the parent plugin then build the child plugin.
+      - '{plugin-name}-gerrit-plugin-{plugin-branch}':
+          gerrit-branch: 'openstack/2.11.4'
+          plugin-name: 'its-storyboard'
+          plugin-project: 'https://gerrit.googlesource.com/plugins/{plugin-name}'
+          plugin-parent-name: 'its-base'
+          plugin-parent-project: 'https://gerrit.googlesource.com/plugins/{plugin-parent-name}'
+          plugin-branch: 'stable-2.11'
 
 - project:
     name: gerrit-dash-creator