gerrit: Make triggerOn* parameters really use boolean values.

Parameters triggerOn* are documented as boolean, however, using values like
true or false results in exception "TypeError: cannot serialize True (type
bool)".

Theses values have special meaning in yaml, and are not loaded as string in
python. It was hence required to use quotes to make it work.

Add a sample using thoses attributes as an example.

Change-Id: Iccbda8ebc0867e173fa7ccab78db16874ddb2a45
Reviewed-on: https://review.openstack.org/24262
Reviewed-by: James E. Blair <corvus@inaugust.com>
Reviewed-by: Khai Do <zaro0508@gmail.com>
Reviewed-by: Anita Kuno <akuno@lavabit.com>
Approved: Jeremy Stanley <fungi@yuggoth.org>
Reviewed-by: Jeremy Stanley <fungi@yuggoth.org>
Tested-by: Jenkins
gerrit: Support gerrit-trigger >= 2.6.0.

Gerrit-trigger offers different triggers, stored in config file using
different formats.
During development of version 2.6.0, the following markup was used[1]:

  <triggerOnPatchsetUploadedEvent>true</triggerOnPatchsetUploadedEvent>
  <triggerOnChangeMergedEvent>true</triggerOnChangeMergedEvent>
  <triggerOnCommentAddedEvent>false</triggerOnCommentAddedEvent>
  <triggerOnRefUpdatedEvent>false</triggerOnRefUpdatedEvent>

That markup changed before the release of 2.6.0 [2] to:

  <triggerOnEvents>
    <com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.events.PluginPatchsetCreatedEvent/>
    <com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.events.PluginChangeRestoredEvent/>
  </triggerOnEvents>

Adjust the generated XML tree to match what gerrit-trigger expects.

This means that gerrit-trigger versions < 2.6.0 are no longer supported.

Trigger on draft published, added in 2.6.0, is now supported.

[1] Commit 8bee93a87b59d413ccec0aa84d3da10adb108eb9
[2] Commit 9ba008972a84e3ca8b2a90bd6d21295e7d7f4f94

Change-Id: I7160de1284c53d20f435e5af0d5a64b2e17c4196
Reviewed-on: https://review.openstack.org/24263
Reviewed-by: James E. Blair <corvus@inaugust.com>
Reviewed-by: Jeremy Stanley <fungi@yuggoth.org>
Reviewed-by: Anita Kuno <akuno@lavabit.com>
Approved: Jeremy Stanley <fungi@yuggoth.org>
Tested-by: Jenkins
gerrit: Add support for on changed restored/abandoned.

These triggers are supported starting at gerrit-trigger 2.8.0.

Using thoses triggers in a previous version should not cause any
problem.

Change-Id: I388cfb9424dd16dc436010c492e59dd0e896b69a
Reviewed-on: https://review.openstack.org/24264
Reviewed-by: James E. Blair <corvus@inaugust.com>
Reviewed-by: Jeremy Stanley <fungi@yuggoth.org>
Reviewed-by: Anita Kuno <akuno@lavabit.com>
Approved: Jeremy Stanley <fungi@yuggoth.org>
Tested-by: Jenkins
gerrit: Add support for skipVote.

Newer versions of gerrit-trigger permit builds to forbear, depending of
the build outcome (success, failure, etc.).

This capability is exposed in jenkins-job-builder, with suitable
defaults.

Change-Id: I25e267459b93b8e18a690c4d38989196ca1298f3
Reviewed-on: https://review.openstack.org/24265
Reviewed-by: James E. Blair <corvus@inaugust.com>
Reviewed-by: Jeremy Stanley <fungi@yuggoth.org>
Reviewed-by: Anita Kuno <akuno@lavabit.com>
Reviewed-by: Khai Do <zaro0508@gmail.com>
Approved: Jeremy Stanley <fungi@yuggoth.org>
Tested-by: Jenkins
gerrit: Use hyphenated key names.

Hyphenated strings are now standard in Jenkins Job Builder.

Gerrit Trigger Plugin support used camelCase keys for its
configuration, and is updated to use hyphenated strings.

Old configuration style is still supported: if old key names
are found, they are converted to new style key names.

Change-Id: I3b1968f14029b69497ee543b44070db7d9c3448c
Reviewed-on: https://review.openstack.org/24730
Reviewed-by: James E. Blair <corvus@inaugust.com>
Reviewed-by: Jeremy Stanley <fungi@yuggoth.org>
Reviewed-by: Anita Kuno <akuno@lavabit.com>
Approved: Jeremy Stanley <fungi@yuggoth.org>
Tested-by: Jenkins
restore ability to pass multiple jobs on 'update'

4f5cfb17 gave us the ability to pass multiple job names when running the
`update` command.  Unfortunately the argument parser was made to request
at least one argument.  a0ccb45c fixed it to be one optional argument
which in turn broke the ability to pass several jobs.

This patch makes the names argument to consume all remaining arguments
and not require any.

Change-Id: I4723117d607f7e10223985fdcbdd50fc5ca50183
Reviewed-on: https://review.openstack.org/24711
Reviewed-by: will soula <william.soula@drillinginfo.com>
Reviewed-by: Khai Do <zaro0508@gmail.com>
Reviewed-by: Antoine Musso <hashar@free.fr>
Reviewed-by: James E. Blair <corvus@inaugust.com>
Approved: Jeremy Stanley <fungi@yuggoth.org>
Reviewed-by: Jeremy Stanley <fungi@yuggoth.org>
Tested-by: Jenkins
job now supports a custom workspace

In Jenkins, the job advanced options has a tick box to enable a
workspace space different from the default provided internally by
Jenkins.  The XML element is <customWorkspace />.

Change-Id: Ia432d98523a7cb617c1236acb52821a82b67c8e7
Reviewed-on: https://review.openstack.org/24427
Reviewed-by: Arnaud Fabre <fabre.arnaud@gmail.com>
Reviewed-by: James E. Blair <corvus@inaugust.com>
Reviewed-by: Khai Do <zaro0508@gmail.com>
Approved: Jeremy Stanley <fungi@yuggoth.org>
Reviewed-by: Jeremy Stanley <fungi@yuggoth.org>
Tested-by: Jenkins
Jobs not tied to a node can roam

Previously if you did not specify a node for a job to build on
then the job would be marked as tied to master.  The checkbox for
'Restrict where this project can be run' would be checked but
nothing entered into the textbox so it ended up tied to master.
This change adds an else to the check for 'node' and if 'node' is
not found then canRoam is set to true.  This is a two line change
to modules/general.py

Change-Id: Id7e40ba5ae2eaa92fd7678da7b3acefc1ba4ee32
Reviewed-on: https://review.openstack.org/24669
Reviewed-by: Khai Do <zaro0508@gmail.com>
Reviewed-by: James E. Blair <corvus@inaugust.com>
Approved: Jeremy Stanley <fungi@yuggoth.org>
Reviewed-by: Jeremy Stanley <fungi@yuggoth.org>
Tested-by: Jenkins
job cache now varies by remote url

When updating different Jenkins installations, JJB would end up
invalidating the job cache.  By adding the jenkins.url in the cache file
name, we can maintain a job cache per remote Jenkins instance.

Name of the cache file is based on Jenkins URL.

Change-Id: Ib9c08d8029267729e7a030a4e8bc0a9f05eb8ce3
Reviewed-on: https://review.openstack.org/24404
Reviewed-by: Arnaud Fabre <fabre.arnaud@gmail.com>
Approved: Jeremy Stanley <fungi@yuggoth.org>
Reviewed-by: Jeremy Stanley <fungi@yuggoth.org>
Tested-by: Jenkins