Add support for multiple Gerrit servers in Gerrit trigger

Since version 2.11.0 the Gerrit Trigger Plugin can be configured
to trigger on more than one server.

Change-Id: I2082c5cfd14cd2494e2a7192beeb4909552cb7f6
This commit is contained in:
David Pursehouse 2014-04-11 18:50:38 +09:00
parent 760873403b
commit 3d1f134b45
7 changed files with 90 additions and 1 deletions

View File

@ -197,6 +197,9 @@ def gerrit(parser, xml_parent, data):
trigger configuration will be fetched from there on a regular interval
:arg str custom-url: Custom URL for a message sent to Gerrit. Build
details URL will be used if empty. (default '')
:arg str server-name: Name of the server to trigger on, or ''__ANY__'' to
trigger on any configured Gerrit server (default '__ANY__'). Requires
Gerrit Trigger Plugin version >= 2.11.0
You may select one or more Gerrit events upon which to trigger.
You must also supply at least one project and branch, optionally
@ -210,7 +213,7 @@ def gerrit(parser, xml_parent, data):
Example:
.. literalinclude:: /../../tests/triggers/fixtures/gerrit003.yaml
.. literalinclude:: /../../tests/triggers/fixtures/gerrit004.yaml
"""
logger = logging.getLogger("%s:gerrit" % __name__)
@ -302,6 +305,8 @@ def gerrit(parser, xml_parent, data):
XML.SubElement(gtrig, 'buildUnstableMessage').text = str(
data.get('unstable-message', ''))
XML.SubElement(gtrig, 'customUrl').text = str(data.get('custom-url', ''))
XML.SubElement(gtrig, 'serverName').text = str(
data.get('server-name', '__ANY__'))
def pollscm(parser, xml_parent, data):

View File

@ -43,6 +43,7 @@
<buildSuccessfulMessage/>
<buildUnstableMessage/>
<customUrl/>
<serverName>__ANY__</serverName>
</com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.GerritTrigger>
</triggers>
</project>

View File

@ -47,6 +47,7 @@
<buildSuccessfulMessage/>
<buildUnstableMessage/>
<customUrl/>
<serverName>__ANY__</serverName>
</com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.GerritTrigger>
</triggers>
</project>

View File

@ -63,6 +63,7 @@
<buildSuccessfulMessage/>
<buildUnstableMessage/>
<customUrl/>
<serverName>__ANY__</serverName>
</com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.GerritTrigger>
</triggers>
</project>

View File

@ -0,0 +1,53 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<triggers class="vector">
<com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.GerritTrigger>
<spec/>
<gerritProjects>
<com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.GerritProject>
<compareType>PLAIN</compareType>
<pattern>test-project</pattern>
<branches>
<com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.Branch>
<compareType>PLAIN</compareType>
<pattern>master</pattern>
</com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.Branch>
<com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.Branch>
<compareType>PLAIN</compareType>
<pattern>stable</pattern>
</com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.Branch>
</branches>
<filePaths>
<com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.FilePath>
<compareType>ANT</compareType>
<pattern>subdirectory/**</pattern>
</com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.FilePath>
</filePaths>
</com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.GerritProject>
</gerritProjects>
<skipVote>
<onSuccessful>true</onSuccessful>
<onFailed>true</onFailed>
<onUnstable>true</onUnstable>
<onNotBuilt>true</onNotBuilt>
</skipVote>
<silentMode>false</silentMode>
<escapeQuotes>false</escapeQuotes>
<noNameAndEmailParameters>false</noNameAndEmailParameters>
<dynamicTriggerConfiguration>True</dynamicTriggerConfiguration>
<triggerConfigURL>http://myhost/mytrigger</triggerConfigURL>
<triggerOnEvents>
<com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.events.PluginCommentAddedEvent>
<verdictCategory>APRV</verdictCategory>
<commentAddedTriggerApprovalValue>1</commentAddedTriggerApprovalValue>
</com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.events.PluginCommentAddedEvent>
</triggerOnEvents>
<buildStartMessage/>
<buildFailureMessage/>
<buildSuccessfulMessage/>
<buildUnstableMessage/>
<customUrl/>
<serverName>my-server</serverName>
</com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.GerritTrigger>
</triggers>
</project>

View File

@ -0,0 +1,27 @@
triggers:
- gerrit:
trigger-on-comment-added-event: true
trigger-approval-category: 'APRV'
trigger-approval-value: 1
projects:
- project-compare-type: 'PLAIN'
project-pattern: 'test-project'
branches:
- branch-compare-type: 'PLAIN'
branch-pattern: 'master'
- branch-compare-type: 'PLAIN'
branch-pattern: 'stable'
file-paths:
- compare-type: ANT
pattern: subdirectory/**
skip-vote:
successful: true
failed: true
unstable: true
notbuilt: true
silent: false
escape-quotes: false
no-name-and-email: false
dynamic-trigger-enabled: true
dynamic-trigger-url: http://myhost/mytrigger
server-name: my-server

View File

@ -81,6 +81,7 @@
<buildSuccessfulMessage/>
<buildUnstableMessage/>
<customUrl/>
<serverName>__ANY__</serverName>
</com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.GerritTrigger>
</triggers>
<builders>