Add support for FTP-Publisher plugin
Change-Id: Ibc6af89f99b2f5f0f2e526162c1dd0a16c1b118f Signed-off-by: Kien Ha <kienha9922@gmail.com>
This commit is contained in:
parent
089d9c7cc0
commit
eae4687264
@ -1065,6 +1065,62 @@ def ftp(registry, xml_parent, data):
|
||||
XML.SubElement(transfer_node, 'asciiMode').text = 'false'
|
||||
|
||||
|
||||
def ftp_publisher(registry, xml_parent, data):
|
||||
"""yaml: ftp-publisher
|
||||
This plugin can be used to upload project artifacts and whole directories
|
||||
to an ftp server.
|
||||
Requires the Jenkins :jenkins-wiki:`FTP-Publisher Plugin
|
||||
<FTP-Publisher+Plugin>`.
|
||||
|
||||
:arg list uploads: List of files to upload
|
||||
|
||||
:uploads:
|
||||
* **file-path** ('str') -- Destination folder. It will be created
|
||||
if doesn't exists. Created relative to ftp root directory.
|
||||
(default '')
|
||||
* **source-file** ('str') -- Source files which will be uploaded
|
||||
(default '')
|
||||
:arg str site-name: Name of FTP server to upload to (required)
|
||||
:arg bool use-timestamps: Use timestamps in the FTP directory path (default
|
||||
false)
|
||||
:arg bool flatten-files: Flatten files on the FTP host (default false)
|
||||
:arg bool skip-publishing: Skip publishing (default false)
|
||||
|
||||
Minimal Example:
|
||||
|
||||
.. literalinclude::
|
||||
/../../tests/publishers/fixtures/ftp-publisher-minimal.yaml
|
||||
:language: yaml
|
||||
|
||||
Full Example:
|
||||
|
||||
.. literalinclude::
|
||||
/../../tests/publishers/fixtures/ftp-publisher-full.yaml
|
||||
:language: yaml
|
||||
"""
|
||||
ftp = XML.SubElement(xml_parent, 'com.zanox.hudson.plugins.FTPPublisher')
|
||||
ftp.set('plugin', 'ftppublisher')
|
||||
|
||||
entries = XML.SubElement(ftp, 'entries')
|
||||
if 'uploads' in data:
|
||||
upload_mapping = [
|
||||
('file-path', 'filePath', ''),
|
||||
('source-file', 'sourceFile', ''),
|
||||
]
|
||||
for upload in data['uploads']:
|
||||
entry = XML.SubElement(entries, 'com.zanox.hudson.plugins.Entry')
|
||||
helpers.convert_mapping_to_xml(
|
||||
entry, upload, upload_mapping, fail_required=True)
|
||||
|
||||
mapping = [
|
||||
('site-name', 'siteName', None),
|
||||
('use-timestamps', 'useTimestamps', False),
|
||||
('flatten-files', 'flatten', False),
|
||||
('skip-publishing', 'skip', False),
|
||||
]
|
||||
helpers.convert_mapping_to_xml(ftp, data, mapping, fail_required=True)
|
||||
|
||||
|
||||
def junit(registry, xml_parent, data):
|
||||
"""yaml: junit
|
||||
Publish JUnit test results.
|
||||
|
21
tests/publishers/fixtures/ftp-publisher-full.xml
Normal file
21
tests/publishers/fixtures/ftp-publisher-full.xml
Normal file
@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<publishers>
|
||||
<com.zanox.hudson.plugins.FTPPublisher plugin="ftppublisher">
|
||||
<entries>
|
||||
<com.zanox.hudson.plugins.Entry>
|
||||
<filePath>destination/folder</filePath>
|
||||
<sourceFile>folder/dist/*.jar</sourceFile>
|
||||
</com.zanox.hudson.plugins.Entry>
|
||||
<com.zanox.hudson.plugins.Entry>
|
||||
<filePath>foo/bar</filePath>
|
||||
<sourceFile>foo/bar/*.ear</sourceFile>
|
||||
</com.zanox.hudson.plugins.Entry>
|
||||
</entries>
|
||||
<siteName>foo</siteName>
|
||||
<useTimestamps>true</useTimestamps>
|
||||
<flatten>true</flatten>
|
||||
<skip>true</skip>
|
||||
</com.zanox.hudson.plugins.FTPPublisher>
|
||||
</publishers>
|
||||
</project>
|
11
tests/publishers/fixtures/ftp-publisher-full.yaml
Normal file
11
tests/publishers/fixtures/ftp-publisher-full.yaml
Normal file
@ -0,0 +1,11 @@
|
||||
publishers:
|
||||
- ftp-publisher:
|
||||
uploads:
|
||||
- file-path: destination/folder
|
||||
source-file: folder/dist/*.jar
|
||||
- file-path: foo/bar
|
||||
source-file: foo/bar/*.ear
|
||||
site-name: foo
|
||||
use-timestamps: true
|
||||
flatten-files: true
|
||||
skip-publishing: true
|
12
tests/publishers/fixtures/ftp-publisher-minimal.xml
Normal file
12
tests/publishers/fixtures/ftp-publisher-minimal.xml
Normal file
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<publishers>
|
||||
<com.zanox.hudson.plugins.FTPPublisher plugin="ftppublisher">
|
||||
<entries/>
|
||||
<siteName>foo</siteName>
|
||||
<useTimestamps>false</useTimestamps>
|
||||
<flatten>false</flatten>
|
||||
<skip>false</skip>
|
||||
</com.zanox.hudson.plugins.FTPPublisher>
|
||||
</publishers>
|
||||
</project>
|
3
tests/publishers/fixtures/ftp-publisher-minimal.yaml
Normal file
3
tests/publishers/fixtures/ftp-publisher-minimal.yaml
Normal file
@ -0,0 +1,3 @@
|
||||
publishers:
|
||||
- ftp-publisher:
|
||||
site-name: foo
|
Loading…
Reference in New Issue
Block a user