diff options
author | David Pursehouse <david.pursehouse@sonymobile.com> | 2016-01-26 14:43:03 +0900 |
---|---|---|
committer | David Pursehouse <david.pursehouse@sonymobile.com> | 2016-03-08 14:00:10 +0900 |
commit | e4da33d13b1814aeeae23376a179a1753f152351 (patch) | |
tree | 15abe56d07d86891e62048fa192cdc70e77cb194 | |
parent | 7f595ab04402e687a3aa8eadc532b40217e66626 (diff) | |
download | python-jenkins-job-builder-e4da33d13b1814aeeae23376a179a1753f152351.tar.gz python-jenkins-job-builder-e4da33d13b1814aeeae23376a179a1753f152351.tar.xz python-jenkins-job-builder-e4da33d13b1814aeeae23376a179a1753f152351.zip |
Allow to omit list of projects in Gerrit trigger config
In some cases, for example when using the dynamic trigger config, the
list of projects is not needed. Allow to omit the 'projects' section
of the configuration.
Change-Id: I7c9d2ed03b305ee7c7379564c4b73de1991278f4
-rw-r--r-- | jenkins_jobs/modules/triggers.py | 4 | ||||
-rw-r--r-- | tests/triggers/fixtures/gerrit009.xml | 40 | ||||
-rw-r--r-- | tests/triggers/fixtures/gerrit009.yaml | 8 |
3 files changed, 50 insertions, 2 deletions
diff --git a/jenkins_jobs/modules/triggers.py b/jenkins_jobs/modules/triggers.py index 0efd57be..410c5563 100644 --- a/jenkins_jobs/modules/triggers.py +++ b/jenkins_jobs/modules/triggers.py @@ -80,7 +80,7 @@ def gerrit_handle_legacy_configuration(data): 'skipVote', ]) - for project in data['projects']: + for project in data.get('projects', []): convert_dict(project, [ 'projectCompareType', 'projectPattern', @@ -443,7 +443,7 @@ def gerrit(parser, xml_parent, data): gerrit_handle_legacy_configuration(data) - projects = data['projects'] + projects = data.get('projects', []) gtrig = XML.SubElement(xml_parent, 'com.sonyericsson.hudson.plugins.gerrit.trigger.' 'hudsontrigger.GerritTrigger') diff --git a/tests/triggers/fixtures/gerrit009.xml b/tests/triggers/fixtures/gerrit009.xml new file mode 100644 index 00000000..f7ef95fc --- /dev/null +++ b/tests/triggers/fixtures/gerrit009.xml @@ -0,0 +1,40 @@ +<?xml version="1.0" encoding="utf-8"?> +<project> + <triggers class="vector"> + <com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.GerritTrigger> + <spec/> + <gerritProjects/> + <skipVote> + <onSuccessful>false</onSuccessful> + <onFailed>false</onFailed> + <onUnstable>false</onUnstable> + <onNotBuilt>false</onNotBuilt> + </skipVote> + <silentMode>false</silentMode> + <silentStartMode>false</silentStartMode> + <escapeQuotes>true</escapeQuotes> + <noNameAndEmailParameters>false</noNameAndEmailParameters> + <readableMessage>false</readableMessage> + <dependencyJobsNames/> + <notificationLevel/> + <dynamicTriggerConfiguration>True</dynamicTriggerConfiguration> + <triggerConfigURL>http://myhost/mytrigger</triggerConfigURL> + <allowTriggeringUnreviewedPatches>false</allowTriggeringUnreviewedPatches> + <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> + <com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.events.PluginChangeAbandonedEvent/> + </triggerOnEvents> + <buildStartMessage/> + <buildFailureMessage/> + <buildSuccessfulMessage/> + <buildUnstableMessage/> + <buildNotBuiltMessage/> + <buildUnsuccessfulFilepath/> + <customUrl/> + <serverName>__ANY__</serverName> + </com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.GerritTrigger> + </triggers> +</project> diff --git a/tests/triggers/fixtures/gerrit009.yaml b/tests/triggers/fixtures/gerrit009.yaml new file mode 100644 index 00000000..e5053d20 --- /dev/null +++ b/tests/triggers/fixtures/gerrit009.yaml @@ -0,0 +1,8 @@ +triggers: + - gerrit: + trigger-on-comment-added-event: true + trigger-approval-category: 'APRV' + trigger-approval-value: -1 + trigger-on-change-abandoned-event: true + dynamic-trigger-enabled: true + dynamic-trigger-url: http://myhost/mytrigger |