Add support for forbidden file paths in gerrit trigger
JJB Gerrit Trigger lacks functionality of skipping triggering of jobs if a change impacts certain paths. This change introduces support for this functionality. Change-Id: I5a1940933544932bdf00b9702e0749f31fb32f09 Signed-off-by: Fatih Degirmenci <fatih.degirmenci@ericsson.com>
This commit is contained in:
parent
746d477152
commit
65cb720feb
|
@ -351,6 +351,15 @@ def gerrit(parser, xml_parent, data):
|
|||
* **pattern** (`str`) -- File path pattern to
|
||||
match
|
||||
|
||||
* **forbidden-file-paths** (`list`) -- List of file paths to
|
||||
skip triggering (optional)
|
||||
|
||||
:Forbidden File Path: * **compare-type** (`str`) --
|
||||
''PLAIN'', ''ANT'' or ''REG_EXP'' (optional)
|
||||
(default ''PLAIN'')
|
||||
* **pattern** (`str`) -- File path pattern to
|
||||
match
|
||||
|
||||
* **topics** (`list`) -- List of topics to match
|
||||
(optional)
|
||||
|
||||
|
@ -486,6 +495,20 @@ def gerrit(parser, xml_parent, data):
|
|||
'compare-type', file_path.get('compare-type', 'PLAIN'))
|
||||
XML.SubElement(fp_tag, 'pattern').text = file_path['pattern']
|
||||
|
||||
project_forbidden_file_paths = project.get('forbidden-file-paths', [])
|
||||
if project_forbidden_file_paths:
|
||||
ffps_tag = XML.SubElement(gproj, 'forbiddenFilePaths')
|
||||
for forbidden_file_path in project_forbidden_file_paths:
|
||||
ffp_tag = XML.SubElement(ffps_tag,
|
||||
'com.sonyericsson.hudson.plugins.'
|
||||
'gerrit.trigger.hudsontrigger.data.'
|
||||
'FilePath')
|
||||
XML.SubElement(ffp_tag, 'compareType').text = get_compare_type(
|
||||
'compare-type', forbidden_file_path.get('compare-type',
|
||||
'PLAIN'))
|
||||
XML.SubElement(ffp_tag, 'pattern').text = \
|
||||
forbidden_file_path['pattern']
|
||||
|
||||
topics = project.get('topics', [])
|
||||
if topics:
|
||||
topics_tag = XML.SubElement(gproj, 'topics')
|
||||
|
|
|
@ -0,0 +1,77 @@
|
|||
<?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>PLAIN</compareType>
|
||||
<pattern>**</pattern>
|
||||
</com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.FilePath>
|
||||
</filePaths>
|
||||
<forbiddenFilePaths>
|
||||
<com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.FilePath>
|
||||
<compareType>ANT</compareType>
|
||||
<pattern>subdirectory/**</pattern>
|
||||
</com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.FilePath>
|
||||
</forbiddenFilePaths>
|
||||
<topics>
|
||||
<com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.Topic>
|
||||
<compareType>ANT</compareType>
|
||||
<pattern>refactor-xy**</pattern>
|
||||
</com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.Topic>
|
||||
</topics>
|
||||
</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>
|
||||
<silentStartMode>true</silentStartMode>
|
||||
<escapeQuotes>false</escapeQuotes>
|
||||
<noNameAndEmailParameters>false</noNameAndEmailParameters>
|
||||
<readableMessage>false</readableMessage>
|
||||
<dependencyJobsNames>job1, job2</dependencyJobsNames>
|
||||
<notificationLevel>ALL</notificationLevel>
|
||||
<dynamicTriggerConfiguration>True</dynamicTriggerConfiguration>
|
||||
<triggerConfigURL>http://myhost/mytrigger</triggerConfigURL>
|
||||
<allowTriggeringUnreviewedPatches>true</allowTriggeringUnreviewedPatches>
|
||||
<triggerOnEvents>
|
||||
<com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.events.PluginPatchsetCreatedEvent>
|
||||
<excludeDrafts>true</excludeDrafts>
|
||||
<excludeTrivialRebase>true</excludeTrivialRebase>
|
||||
<excludeNoCodeChange>true</excludeNoCodeChange>
|
||||
</com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.events.PluginPatchsetCreatedEvent>
|
||||
<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/>
|
||||
<buildNotBuiltMessage/>
|
||||
<buildUnsuccessfulFilepath>path/to/filename</buildUnsuccessfulFilepath>
|
||||
<customUrl/>
|
||||
<serverName>my-server</serverName>
|
||||
</com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.GerritTrigger>
|
||||
</triggers>
|
||||
</project>
|
|
@ -0,0 +1,42 @@
|
|||
triggers:
|
||||
- gerrit:
|
||||
trigger-on:
|
||||
- patchset-created-event:
|
||||
exclude-drafts: true
|
||||
exclude-trivial-rebase: true
|
||||
exclude-no-code-change: true
|
||||
- comment-added-event:
|
||||
approval-category: 'APRV'
|
||||
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:
|
||||
- pattern: '**'
|
||||
forbidden-file-paths:
|
||||
- compare-type: ANT
|
||||
pattern: subdirectory/**
|
||||
topics:
|
||||
- compare-type: ANT
|
||||
pattern: refactor-xy**
|
||||
skip-vote:
|
||||
successful: true
|
||||
failed: true
|
||||
unstable: true
|
||||
notbuilt: true
|
||||
silent: false
|
||||
silent-start: true
|
||||
escape-quotes: false
|
||||
no-name-and-email: false
|
||||
dependency-jobs: 'job1, job2'
|
||||
notification-level: ALL
|
||||
dynamic-trigger-enabled: true
|
||||
dynamic-trigger-url: http://myhost/mytrigger
|
||||
trigger-for-unreviewed-patches: true
|
||||
server-name: my-server
|
||||
failure-message-file: path/to/filename
|
Loading…
Reference in New Issue