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
Adding GitHub Pull Request Builder Plugin

Adding the ability to use the GitHub Pull Request Builder plugin.
This plugin requires modifications on the Configure System page
of Jenkins to work properly.  If using GitHub Enterprise you must
set the token on this page, password does not work.  This change
affects the modules/triggers.py and setup.py file, adding a new
section for this plugin.  When using this plugin in the GUI the
textboxes for admin list and crontab will default to the values
stored on the main Configure System Jenkins page, I don't think
JJB can even attempt this default so I just defaulted to nothing.

Change-Id: Ib453cee269038e04f01a446378922b36307c18ce
Reviewed-on: https://review.openstack.org/24929
Reviewed-by: Jeremy Stanley <fungi@yuggoth.org>
Approved: James E. Blair <corvus@inaugust.com>
Reviewed-by: James E. Blair <corvus@inaugust.com>
Tested-by: Jenkins
Add Sonar Plugin support.

The Sonar Plugin provides both a builder and a publisher,
the later targeting Maven projects.

This commit adds support for the publisher, which is straightforward
to configure: no option is required, the plugin finds suitable
defaults by itself.

Several parameters can be provided though, which are transferred
as is to either Sonar or Maven. Analysis can also be skipped under
certain conditions.

Change-Id: I30744d0961d623cabf7c0780ab2f0d4db2cd9295
Reviewed-on: https://review.openstack.org/25073
Reviewed-by: Jeremy Stanley <fungi@yuggoth.org>
Approved: Monty Taylor <mordred@inaugust.com>
Reviewed-by: Monty Taylor <mordred@inaugust.com>
Tested-by: Jenkins
prevent duplicate XML expansion of job templates

Whenever a project has different values for a project and that parameter
is not used in the template, we ended up regenerating the exact same
job.

This patch getXMLForTemplateJob() to make it remember whether an
expanded template has already had its XML generated.  I am using json
which let us serialize an arbitrary data structure and more specially
let us sort the dictionary keys to make sure we always end up with the
same serialization.

The `test` time for my setup went from 34 seconds down to 17 seconds.

Change-Id: I8f4ea2780025fefd3ba58e2ed32d4bd762093acf
Reviewed-on: https://review.openstack.org/24409
Reviewed-by: Arnaud Fabre <fabre.arnaud@gmail.com>
Reviewed-by: Jeremy Stanley <fungi@yuggoth.org>
Reviewed-by: Khai Do <zaro0508@gmail.com>
Reviewed-by: Monty Taylor <mordred@inaugust.com>
Approved: James E. Blair <corvus@inaugust.com>
Reviewed-by: James E. Blair <corvus@inaugust.com>
Tested-by: Jenkins
Adding Top-Level Maven Targets

Adding ability to use top-level maven targets within your build.
This is a change to the builders file and setup.py to add the new
functionality.

Change-Id: I7ae24b82d0b0ba4e81eda67045131733ced1dc46
Reviewed-on: https://review.openstack.org/25413
Reviewed-by: Khai Do <zaro0508@gmail.com>
Reviewed-by: Arnaud Fabre <fabre.arnaud@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
gerrit: Add file paths filtering support.

Gerrit Trigger allows to restrict triggering of build depending
on which files are modified in the change.

Expose this capability with a new property file-paths.

Also cleanup documentation (omissions and formatting errors).

Change-Id: I4bfc5ab03a10622fdb5730a294037add8c1ad54f
Reviewed-on: https://review.openstack.org/25569
Reviewed-by: Antoine Musso <hashar@free.fr>
Reviewed-by: Clark Boylan <clark.boylan@gmail.com>
Approved: Jeremy Stanley <fungi@yuggoth.org>
Reviewed-by: Jeremy Stanley <fungi@yuggoth.org>
Tested-by: Jenkins
matrix jobs now supports user-defined axes

The XML definition of a user defined axes is the same as a a labeled
expression axis.  Only the XML element name change, adding support for
user defined axis is thus only a matter of adding a map between our YAML
values and Jenkins XML element name.

Change-Id: Ib2f36e10c1c5fb14f0e4255f35c0bf19c2cc39b3
Reviewed-on: https://review.openstack.org/25432
Reviewed-by: Arnaud Fabre <fabre.arnaud@gmail.com>
Reviewed-by: Clark Boylan <clark.boylan@gmail.com>
Reviewed-by: Khai Do <zaro0508@gmail.com>
Approved: Jeremy Stanley <fungi@yuggoth.org>
Reviewed-by: Jeremy Stanley <fungi@yuggoth.org>
Tested-by: Jenkins
add an auth-token YAML parameter for the General Job Configuraion module

Using the Jenkins WEB UI an Authentication Token can be specified for
jobs to allow builds to be triggered remotely by using the URL:
JENKINS_URL/job/JOBNAME/build?token=TOKEN

Add an auth-token job parameter to generate the <authToken> XML element.

Change-Id: Ic916e4074c9b2de9c616ef39a88c1d8e1e91fcff
Signed-off-by: Javier Martinez Canillas <martinez.javier@gmail.com>
Reviewed-on: https://review.openstack.org/25819
Reviewed-by: Arnaud Fabre <fabre.arnaud@gmail.com>
Reviewed-by: Clark Boylan <clark.boylan@gmail.com>
Approved: James E. Blair <corvus@inaugust.com>
Reviewed-by: James E. Blair <corvus@inaugust.com>
Tested-by: Jenkins
Adding 'switches' to gradle

This change adds the ability to specify switches to be passed to
gradle.  This change was only two functional code lines and
several lines of documentation.  The only file that changed was
builders.py

Change-Id: Idb1199cd4a63e6fbfdabe57cf50a8b431dd9e914
Reviewed-on: https://review.openstack.org/25929
Reviewed-by: Tollef Fog Heen <tfheen@varnish-software.com>
Reviewed-by: Arnaud Fabre <fabre.arnaud@gmail.com>
Reviewed-by: Clark Boylan <clark.boylan@gmail.com>
Approved: James E. Blair <corvus@inaugust.com>
Reviewed-by: James E. Blair <corvus@inaugust.com>
Tested-by: Jenkins
Maven: Fix XML markup.

The generated markup contains a node "root_module", which is not
recognized by Jenkins:

  WARNING: Skipping a non-existent field root_module
  com.thoughtworks.xstream.converters.reflection.MissingFieldException: No
  field 'root_module' found in class 'hudson.maven.MavenModuleSet'

The correct spelling is rootModule.

Change-Id: I0cae2c3358f2664783c97e245b064453a05bc988
Reviewed-on: https://review.openstack.org/26052
Reviewed-by: James E. Blair <corvus@inaugust.com>
Approved: Clark Boylan <clark.boylan@gmail.com>
Reviewed-by: Clark Boylan <clark.boylan@gmail.com>
Tested-by: Jenkins
Add jenkins-jobs command line tool.

So that jenkins-jobs can be easily run for testing from the source
dir without installation.

Change-Id: Iabba59ad32ccd4b79eb8934e53c6d747110a06b0
Reviewed-on: https://review.openstack.org/26259
Reviewed-by: Clark Boylan <clark.boylan@gmail.com>
Approved: Monty Taylor <mordred@inaugust.com>
Reviewed-by: Monty Taylor <mordred@inaugust.com>
Tested-by: Jenkins
Add support for password parameters

Change-Id: Iaab1d59c6e01fb95f5c8cd012dbc73379c92174e
Reviewed-on: https://review.openstack.org/26317
Reviewed-by: Monty Taylor <mordred@inaugust.com>
Reviewed-by: James E. Blair <corvus@inaugust.com>
Approved: James E. Blair <corvus@inaugust.com>
Tested-by: Jenkins