Merge "Adding support to monitor folders using FS trigger plugin"
This commit is contained in:
commit
dc28559b05
@ -1003,6 +1003,49 @@ def reverse(parser, xml_parent, data):
|
|||||||
str(hudson_model.THRESHOLDS[result]['complete']).lower()
|
str(hudson_model.THRESHOLDS[result]['complete']).lower()
|
||||||
|
|
||||||
|
|
||||||
|
def monitor_folders(parser, xml_parent, data):
|
||||||
|
"""yaml: monitor-folders
|
||||||
|
Configure Jenkins to monitor folders.
|
||||||
|
Requires the Jenkins :jenkins-wiki:`Filesystem Trigger Plugin
|
||||||
|
<FSTriggerPlugin>`.
|
||||||
|
|
||||||
|
:arg str path: Folder path to poll. (optional)
|
||||||
|
:arg list includes: Fileset includes setting that specifies the list of
|
||||||
|
includes files. Basedir of the fileset is relative to the workspace
|
||||||
|
root. If no value is set, all files are used. (optional)
|
||||||
|
:arg str excludes: The 'excludes' pattern. A file that matches this mask
|
||||||
|
will not be polled even if it matches the mask specified in 'includes'
|
||||||
|
section. (optional)
|
||||||
|
:arg bool check-modification-date: Check last modification date.
|
||||||
|
(default true)
|
||||||
|
:arg bool check-content: Check content. (default true)
|
||||||
|
:arg bool check-fewer: Check fewer or more files (default true)
|
||||||
|
:arg str cron: cron syntax of when to run (default '')
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
.. literalinclude:: /../../tests/triggers/fixtures/monitor_folders.yaml
|
||||||
|
"""
|
||||||
|
ft = XML.SubElement(xml_parent, ('org.jenkinsci.plugins.fstrigger.'
|
||||||
|
'triggers.FolderContentTrigger'))
|
||||||
|
path = data.get('path')
|
||||||
|
if path:
|
||||||
|
XML.SubElement(ft, 'path').text = path
|
||||||
|
includes = data.get('includes')
|
||||||
|
if includes:
|
||||||
|
XML.SubElement(ft, 'includes').text = ",".join(includes)
|
||||||
|
excludes = data.get('excludes')
|
||||||
|
if excludes:
|
||||||
|
XML.SubElement(ft, 'excludes').text = excludes
|
||||||
|
XML.SubElement(ft, 'spec').text = data.get('cron', '')
|
||||||
|
XML.SubElement(ft, 'excludeCheckLastModificationDate').text = str(
|
||||||
|
not data.get('check-modification-date', True)).lower()
|
||||||
|
XML.SubElement(ft, 'excludeCheckContent').text = str(
|
||||||
|
not data.get('check-content', True)).lower()
|
||||||
|
XML.SubElement(ft, 'excludeCheckFewerOrMoreFiles').text = str(
|
||||||
|
not data.get('check-fewer', True)).lower()
|
||||||
|
|
||||||
|
|
||||||
def ivy(parser, xml_parent, data):
|
def ivy(parser, xml_parent, data):
|
||||||
"""yaml: ivy
|
"""yaml: ivy
|
||||||
Poll with an Ivy script
|
Poll with an Ivy script
|
||||||
|
@ -234,6 +234,7 @@ jenkins_jobs.triggers =
|
|||||||
gitlab-merge-request=jenkins_jobs.modules.triggers:gitlab_merge_request
|
gitlab-merge-request=jenkins_jobs.modules.triggers:gitlab_merge_request
|
||||||
groovy-script=jenkins_jobs.modules.triggers:groovy_script
|
groovy-script=jenkins_jobs.modules.triggers:groovy_script
|
||||||
ivy=jenkins_jobs.modules.triggers:ivy
|
ivy=jenkins_jobs.modules.triggers:ivy
|
||||||
|
monitor-folders=jenkins_jobs.modules.triggers:monitor_folders
|
||||||
pollscm=jenkins_jobs.modules.triggers:pollscm
|
pollscm=jenkins_jobs.modules.triggers:pollscm
|
||||||
raw=jenkins_jobs.modules.general:raw
|
raw=jenkins_jobs.modules.general:raw
|
||||||
reverse=jenkins_jobs.modules.triggers:reverse
|
reverse=jenkins_jobs.modules.triggers:reverse
|
||||||
|
14
tests/triggers/fixtures/monitor_folders.xml
Normal file
14
tests/triggers/fixtures/monitor_folders.xml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<project>
|
||||||
|
<triggers class="vector">
|
||||||
|
<org.jenkinsci.plugins.fstrigger.triggers.FolderContentTrigger>
|
||||||
|
<path>pathname</path>
|
||||||
|
<includes>pattern1,pattern2</includes>
|
||||||
|
<excludes>pattern1</excludes>
|
||||||
|
<spec>H/15 * * * *</spec>
|
||||||
|
<excludeCheckLastModificationDate>true</excludeCheckLastModificationDate>
|
||||||
|
<excludeCheckContent>true</excludeCheckContent>
|
||||||
|
<excludeCheckFewerOrMoreFiles>true</excludeCheckFewerOrMoreFiles>
|
||||||
|
</org.jenkinsci.plugins.fstrigger.triggers.FolderContentTrigger>
|
||||||
|
</triggers>
|
||||||
|
</project>
|
11
tests/triggers/fixtures/monitor_folders.yaml
Normal file
11
tests/triggers/fixtures/monitor_folders.yaml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
triggers:
|
||||||
|
- monitor-folders:
|
||||||
|
path: 'pathname'
|
||||||
|
includes:
|
||||||
|
- 'pattern1'
|
||||||
|
- 'pattern2'
|
||||||
|
excludes: 'pattern1'
|
||||||
|
check-modification-date: false
|
||||||
|
check-content: false
|
||||||
|
check-fewer: false
|
||||||
|
cron: 'H/15 * * * *'
|
Loading…
Reference in New Issue
Block a user