Add 'publish-over-cifs' to the builders module
This adds the 'publish-over-cifs' action to the builders module. It enables the "Send files to a windows share" build step, provided by the "Publish Over CIFS Plugin". Change-Id: I80cb2f86091ef53a284cf85a381294bbb6133010
This commit is contained in:
parent
539d13e816
commit
a1dba99eb7
@ -51,6 +51,7 @@ import jenkins_jobs.modules.helpers as helpers
|
||||
import pkg_resources
|
||||
from jenkins_jobs.modules import hudson_model
|
||||
from jenkins_jobs.modules.publishers import ssh
|
||||
from jenkins_jobs.modules.publishers import cifs
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@ -2339,6 +2340,34 @@ def publish_over_ssh(registry, xml_parent, data):
|
||||
ssh(registry, xml_parent, data)
|
||||
|
||||
|
||||
def publish_over_cifs(registry, xml_parent, data):
|
||||
"""yaml: publish-over-cifs
|
||||
Upload files via CIFS.
|
||||
Requires the Jenkins :jenkins-wiki:`Publish over CIFS Plugin
|
||||
<Publish+Over+CIFS+Plugin>`.
|
||||
|
||||
:arg str site: name of the ssh site
|
||||
:arg str target: destination directory
|
||||
:arg bool target-is-date-format: whether target is a date format. If true,
|
||||
raw text should be quoted (default false)
|
||||
:arg bool clean-remote: should the remote directory be deleted before
|
||||
transferring files (default false)
|
||||
:arg str source: source path specifier
|
||||
:arg str excludes: excluded file pattern (optional)
|
||||
:arg str remove-prefix: prefix to remove from uploaded file paths
|
||||
(optional)
|
||||
:arg bool fail-on-error: fail the build if an error occurs (default false)
|
||||
:arg bool flatten: only create files on the server, don't create
|
||||
directories (default false)
|
||||
|
||||
Example:
|
||||
|
||||
.. literalinclude:: /../../tests/builders/fixtures/publish-over-cifs.yaml
|
||||
:language: yaml
|
||||
"""
|
||||
cifs(registry, xml_parent, data)
|
||||
|
||||
|
||||
def saltstack(parser, xml_parent, data):
|
||||
"""yaml: saltstack
|
||||
|
||||
|
@ -1936,11 +1936,13 @@ def ssh(registry, xml_parent, data):
|
||||
|
||||
if xml_parent.tag == 'publishers':
|
||||
plugin_tag = '%s__over__ssh.BapSshPublisherPlugin' % tag_prefix
|
||||
is_builder = False
|
||||
else:
|
||||
plugin_tag = '%s__over__ssh.BapSshBuilderPlugin' % tag_prefix
|
||||
is_builder = True
|
||||
|
||||
base_publish_over(xml_parent, data, console_prefix, plugin_tag,
|
||||
publisher_tag, transfer_tag, reference_tag)
|
||||
publisher_tag, transfer_tag, reference_tag, is_builder)
|
||||
|
||||
|
||||
def pipeline(registry, xml_parent, data):
|
||||
@ -2678,10 +2680,11 @@ def groovy_postbuild(registry, xml_parent, data):
|
||||
|
||||
def base_publish_over(xml_parent, data, console_prefix,
|
||||
plugin_tag, publisher_tag,
|
||||
transferset_tag, reference_plugin_tag):
|
||||
transferset_tag, reference_plugin_tag,
|
||||
is_builder=False):
|
||||
outer = XML.SubElement(xml_parent, plugin_tag)
|
||||
# 'Publish over SSH' builder has an extra top delegate element
|
||||
if xml_parent.tag == 'builders':
|
||||
if xml_parent.tag == 'builders' or is_builder:
|
||||
outer = XML.SubElement(outer, 'delegate')
|
||||
|
||||
XML.SubElement(outer, 'consolePrefix').text = console_prefix
|
||||
@ -2764,7 +2767,12 @@ def cifs(registry, xml_parent, data):
|
||||
|
||||
"""
|
||||
console_prefix = 'CIFS: '
|
||||
plugin_tag = 'jenkins.plugins.publish__over__cifs.CifsPublisherPlugin'
|
||||
if xml_parent.tag == 'publishers':
|
||||
plugin_tag = 'jenkins.plugins.publish__over__cifs.CifsPublisherPlugin'
|
||||
is_builder = False
|
||||
else:
|
||||
plugin_tag = 'jenkins.plugins.publish__over__cifs.CifsBuilderPlugin'
|
||||
is_builder = True
|
||||
publisher_tag = 'jenkins.plugins.publish__over__cifs.CifsPublisher'
|
||||
transfer_tag = 'jenkins.plugins.publish__over__cifs.CifsTransfer'
|
||||
plugin_reference_tag = ('jenkins.plugins.publish_over_cifs.'
|
||||
@ -2775,7 +2783,8 @@ def cifs(registry, xml_parent, data):
|
||||
plugin_tag,
|
||||
publisher_tag,
|
||||
transfer_tag,
|
||||
plugin_reference_tag)
|
||||
plugin_reference_tag,
|
||||
is_builder)
|
||||
|
||||
|
||||
def cigame(registry, xml_parent, data):
|
||||
|
35
tests/builders/fixtures/publish-over-cifs.xml
Normal file
35
tests/builders/fixtures/publish-over-cifs.xml
Normal file
@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<builders>
|
||||
<jenkins.plugins.publish__over__cifs.CifsBuilderPlugin>
|
||||
<delegate>
|
||||
<consolePrefix>CIFS: </consolePrefix>
|
||||
<delegate>
|
||||
<publishers>
|
||||
<jenkins.plugins.publish__over__cifs.CifsPublisher>
|
||||
<configName>cifs.share</configName>
|
||||
<verbose>false</verbose>
|
||||
<transfers>
|
||||
<jenkins.plugins.publish__over__cifs.CifsTransfer>
|
||||
<remoteDirectory>dest/dir</remoteDirectory>
|
||||
<sourceFiles>base/source/dir/**</sourceFiles>
|
||||
<excludes>**/*.excludedfiletype</excludes>
|
||||
<removePrefix>base/source/dir</removePrefix>
|
||||
<remoteDirectorySDF>false</remoteDirectorySDF>
|
||||
<flatten>true</flatten>
|
||||
<cleanRemote>false</cleanRemote>
|
||||
</jenkins.plugins.publish__over__cifs.CifsTransfer>
|
||||
</transfers>
|
||||
<useWorkspaceInPromotion>false</useWorkspaceInPromotion>
|
||||
<usePromotionTimestamp>false</usePromotionTimestamp>
|
||||
</jenkins.plugins.publish__over__cifs.CifsPublisher>
|
||||
</publishers>
|
||||
<continueOnError>false</continueOnError>
|
||||
<failOnError>false</failOnError>
|
||||
<alwaysPublishFromMaster>false</alwaysPublishFromMaster>
|
||||
<hostConfigurationAccess class="jenkins.plugins.publish_over_cifs.CifsPublisherPlugin" reference="../.."/>
|
||||
</delegate>
|
||||
</delegate>
|
||||
</jenkins.plugins.publish__over__cifs.CifsBuilderPlugin>
|
||||
</builders>
|
||||
</project>
|
8
tests/builders/fixtures/publish-over-cifs.yaml
Normal file
8
tests/builders/fixtures/publish-over-cifs.yaml
Normal file
@ -0,0 +1,8 @@
|
||||
builders:
|
||||
- publish-over-cifs:
|
||||
site: 'cifs.share'
|
||||
target: 'dest/dir'
|
||||
source: 'base/source/dir/**'
|
||||
remove-prefix: 'base/source/dir'
|
||||
excludes: '**/*.excludedfiletype'
|
||||
flatten: true
|
Loading…
Reference in New Issue
Block a user