From de4fb862f3469fc711e8adefcb2f2471427a3a84 Mon Sep 17 00:00:00 2001 From: Darragh Bailey Date: Thu, 23 Aug 2018 14:53:47 +0100 Subject: [PATCH] Allow control of verbose option for publish-over plugins The publish-over plugins all expose the option 'verbose' to all for lots of debug output from the connection to be outputted to the jenkins console. However by default this is supposed to be disabled ('false') so update the existing code to switch to the correct behaviour. Change-Id: Ie9acb1a005a25cd5c9f279cc89d5178eb8d54dd7 --- jenkins_jobs/modules/publishers.py | 46 ++++++++++++++----- tests/builders/fixtures/publish-over-ssh.xml | 2 +- tests/publishers/fixtures/cifs-full.xml | 33 +++++++++++++ .../fixtures/{cifs001.yaml => cifs-full.yaml} | 8 +++- .../{cifs001.xml => cifs-minimal.xml} | 8 ++-- tests/publishers/fixtures/cifs-minimal.yaml | 5 ++ tests/publishers/fixtures/ftp-full.xml | 34 ++++++++++++++ tests/publishers/fixtures/ftp-full.yaml | 12 +++++ .../fixtures/{ftp001.xml => ftp-minimal.xml} | 8 ++-- tests/publishers/fixtures/ftp-minimal.yaml | 5 ++ tests/publishers/fixtures/ftp001.yaml | 8 ---- .../fixtures/{ssh001.xml => ssh-full.xml} | 10 ++-- .../fixtures/{ssh001.yaml => ssh-full.yaml} | 13 ++++-- tests/publishers/fixtures/ssh-minimal.xml | 33 +++++++++++++ tests/publishers/fixtures/ssh-minimal.yaml | 5 ++ 15 files changed, 190 insertions(+), 40 deletions(-) create mode 100644 tests/publishers/fixtures/cifs-full.xml rename tests/publishers/fixtures/{cifs001.yaml => cifs-full.yaml} (55%) rename tests/publishers/fixtures/{cifs001.xml => cifs-minimal.xml} (87%) create mode 100644 tests/publishers/fixtures/cifs-minimal.yaml create mode 100644 tests/publishers/fixtures/ftp-full.xml create mode 100644 tests/publishers/fixtures/ftp-full.yaml rename tests/publishers/fixtures/{ftp001.xml => ftp-minimal.xml} (87%) create mode 100644 tests/publishers/fixtures/ftp-minimal.yaml delete mode 100644 tests/publishers/fixtures/ftp001.yaml rename tests/publishers/fixtures/{ssh001.xml => ssh-full.xml} (83%) rename tests/publishers/fixtures/{ssh001.yaml => ssh-full.yaml} (59%) create mode 100644 tests/publishers/fixtures/ssh-minimal.xml create mode 100644 tests/publishers/fixtures/ssh-minimal.yaml diff --git a/jenkins_jobs/modules/publishers.py b/jenkins_jobs/modules/publishers.py index d4593515f..4b29366e5 100644 --- a/jenkins_jobs/modules/publishers.py +++ b/jenkins_jobs/modules/publishers.py @@ -1159,24 +1159,31 @@ def ftp(registry, xml_parent, data): Requires the Jenkins :jenkins-wiki:`Publish over FTP Plugin `. - :arg str site: name of the ftp site - :arg str target: destination directory + :arg str site: name of the ftp site (required) + :arg str target: destination directory (required) :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 source: source path specifier (required) :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). + :arg bool verbose: adds lots of detail useful for debug to the console + but generally should be left off (default false) - Example: + Minimal Example: - .. literalinclude:: /../../tests/publishers/fixtures/ftp001.yaml - :language: yaml + .. literalinclude:: /../../tests/publishers/fixtures/ftp-minimal.yaml + :language: yaml + + Full Example: + + .. literalinclude:: /../../tests/publishers/fixtures/ftp-full.yaml + :language: yaml """ console_prefix = 'FTP: ' @@ -1906,11 +1913,18 @@ def ssh(registry, xml_parent, data): before being sent to the remote server (defaults false) :arg bool flatten: only create files on the server, don't create directories (default false). + :arg bool verbose: adds lots of detail useful for debug to the console + but generally should be left off (default false) - Example: + Minimal Example: - .. literalinclude:: /../../tests/publishers/fixtures/ssh001.yaml - :language: yaml + .. literalinclude:: /../../tests/publishers/fixtures/ssh-minimal.yaml + :language: yaml + + Full Example: + + .. literalinclude:: /../../tests/publishers/fixtures/ssh-full.yaml + :language: yaml """ console_prefix = 'SSH: ' tag_prefix = 'jenkins.plugins.publish' @@ -2674,7 +2688,8 @@ def base_publish_over(xml_parent, data, console_prefix, inner = XML.SubElement(publishers, publisher_tag) XML.SubElement(inner, 'configName').text = data['site'] - XML.SubElement(inner, 'verbose').text = 'true' + XML.SubElement(inner, 'verbose').text = str( + data.get('verbose', False)).lower() transfers = XML.SubElement(inner, 'transfers') transfersset = XML.SubElement(transfers, transferset_tag) @@ -2732,10 +2747,17 @@ def cifs(registry, xml_parent, data): :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). + :arg bool verbose: adds lots of detail useful for debug to the console + but generally should be left off (default false) - Example: + Minimal Example: - .. literalinclude:: /../../tests/publishers/fixtures/cifs001.yaml + .. literalinclude:: /../../tests/publishers/fixtures/cifs-minimal.yaml + :language: yaml + + Full Example: + + .. literalinclude:: /../../tests/publishers/fixtures/cifs-full.yaml :language: yaml """ diff --git a/tests/builders/fixtures/publish-over-ssh.xml b/tests/builders/fixtures/publish-over-ssh.xml index 91f05241e..b347ba1f8 100644 --- a/tests/builders/fixtures/publish-over-ssh.xml +++ b/tests/builders/fixtures/publish-over-ssh.xml @@ -8,7 +8,7 @@ server.example.com - true + false dest/dir diff --git a/tests/publishers/fixtures/cifs-full.xml b/tests/publishers/fixtures/cifs-full.xml new file mode 100644 index 000000000..363348be8 --- /dev/null +++ b/tests/publishers/fixtures/cifs-full.xml @@ -0,0 +1,33 @@ + + + + + CIFS: + + + + cifs.share + true + + + 'dest/dir/'yyyyMMddHHmmss + base/source/dir/** + **/*.excludedfiletype + base/source/dir + true + true + true + + + false + false + + + false + true + false + + + + + diff --git a/tests/publishers/fixtures/cifs001.yaml b/tests/publishers/fixtures/cifs-full.yaml similarity index 55% rename from tests/publishers/fixtures/cifs001.yaml rename to tests/publishers/fixtures/cifs-full.yaml index 7d01766b1..830e28d19 100644 --- a/tests/publishers/fixtures/cifs001.yaml +++ b/tests/publishers/fixtures/cifs-full.yaml @@ -1,8 +1,12 @@ publishers: - cifs: site: 'cifs.share' - target: 'dest/dir' + target: "'dest/dir/'yyyyMMddHHmmss" + target-is-date-format: true + clean-remote: true source: 'base/source/dir/**' - remove-prefix: 'base/source/dir' excludes: '**/*.excludedfiletype' + remove-prefix: 'base/source/dir' + fail-on-error: true flatten: true + verbose: true diff --git a/tests/publishers/fixtures/cifs001.xml b/tests/publishers/fixtures/cifs-minimal.xml similarity index 87% rename from tests/publishers/fixtures/cifs001.xml rename to tests/publishers/fixtures/cifs-minimal.xml index 41e52bc61..145261435 100644 --- a/tests/publishers/fixtures/cifs001.xml +++ b/tests/publishers/fixtures/cifs-minimal.xml @@ -7,15 +7,15 @@ cifs.share - true + false dest/dir base/source/dir/** - **/*.excludedfiletype - base/source/dir + + false - true + false false diff --git a/tests/publishers/fixtures/cifs-minimal.yaml b/tests/publishers/fixtures/cifs-minimal.yaml new file mode 100644 index 000000000..dafe42941 --- /dev/null +++ b/tests/publishers/fixtures/cifs-minimal.yaml @@ -0,0 +1,5 @@ +publishers: + - cifs: + site: 'cifs.share' + target: 'dest/dir' + source: 'base/source/dir/**' diff --git a/tests/publishers/fixtures/ftp-full.xml b/tests/publishers/fixtures/ftp-full.xml new file mode 100644 index 000000000..e36cad8be --- /dev/null +++ b/tests/publishers/fixtures/ftp-full.xml @@ -0,0 +1,34 @@ + + + + + FTP: + + + + ftp.example.com + true + + + 'dest/dir/'yyyyMMddHHmmss + base/source/dir/** + **/*.excludedfiletype + base/source/dir + true + true + true + false + + + false + false + + + false + true + false + + + + + diff --git a/tests/publishers/fixtures/ftp-full.yaml b/tests/publishers/fixtures/ftp-full.yaml new file mode 100644 index 000000000..bd6da1854 --- /dev/null +++ b/tests/publishers/fixtures/ftp-full.yaml @@ -0,0 +1,12 @@ +publishers: + - ftp: + site: 'ftp.example.com' + target: "'dest/dir/'yyyyMMddHHmmss" + target-is-date-format: true + clean-remote: true + source: 'base/source/dir/**' + excludes: '**/*.excludedfiletype' + remove-prefix: 'base/source/dir' + fail-on-error: true + flatten: true + verbose: true diff --git a/tests/publishers/fixtures/ftp001.xml b/tests/publishers/fixtures/ftp-minimal.xml similarity index 87% rename from tests/publishers/fixtures/ftp001.xml rename to tests/publishers/fixtures/ftp-minimal.xml index c6431528a..c5a24b0cb 100644 --- a/tests/publishers/fixtures/ftp001.xml +++ b/tests/publishers/fixtures/ftp-minimal.xml @@ -7,15 +7,15 @@ ftp.example.com - true + false dest/dir base/source/dir/** - **/*.excludedfiletype - base/source/dir + + false - true + false false false diff --git a/tests/publishers/fixtures/ftp-minimal.yaml b/tests/publishers/fixtures/ftp-minimal.yaml new file mode 100644 index 000000000..90f0d66c0 --- /dev/null +++ b/tests/publishers/fixtures/ftp-minimal.yaml @@ -0,0 +1,5 @@ +publishers: + - ftp: + site: 'ftp.example.com' + target: 'dest/dir' + source: 'base/source/dir/**' diff --git a/tests/publishers/fixtures/ftp001.yaml b/tests/publishers/fixtures/ftp001.yaml deleted file mode 100644 index 368aa7d18..000000000 --- a/tests/publishers/fixtures/ftp001.yaml +++ /dev/null @@ -1,8 +0,0 @@ -publishers: -- ftp: - site: 'ftp.example.com' - target: 'dest/dir' - source: 'base/source/dir/**' - remove-prefix: 'base/source/dir' - excludes: '**/*.excludedfiletype' - flatten: true diff --git a/tests/publishers/fixtures/ssh001.xml b/tests/publishers/fixtures/ssh-full.xml similarity index 83% rename from tests/publishers/fixtures/ssh001.xml rename to tests/publishers/fixtures/ssh-full.xml index 44c82d5b8..5a5264908 100644 --- a/tests/publishers/fixtures/ssh001.xml +++ b/tests/publishers/fixtures/ssh-full.xml @@ -10,13 +10,13 @@ true - dest/dir + 'dest/dir/'yyyyMMddHHmmss base/source/dir/** **/*.excludedfiletype base/source/dir - false + true true - false + true rm -r jenkins_$BUILD_NUMBER 1800000 true @@ -27,8 +27,8 @@ false - false - false + true + true diff --git a/tests/publishers/fixtures/ssh001.yaml b/tests/publishers/fixtures/ssh-full.yaml similarity index 59% rename from tests/publishers/fixtures/ssh001.yaml rename to tests/publishers/fixtures/ssh-full.yaml index 344dfd098..fe6e94a1e 100644 --- a/tests/publishers/fixtures/ssh001.yaml +++ b/tests/publishers/fixtures/ssh-full.yaml @@ -1,11 +1,16 @@ publishers: - ssh: site: 'server.example.com' - target: 'dest/dir' + target: "'dest/dir/'yyyyMMddHHmmss" + target-is-date-format: true + clean-remote: true source: 'base/source/dir/**' - remove-prefix: 'base/source/dir' - excludes: '**/*.excludedfiletype' - use-pty: true command: 'rm -r jenkins_$BUILD_NUMBER' timeout: 1800000 + use-pty: true + excludes: '**/*.excludedfiletype' + remove-prefix: 'base/source/dir' + fail-on-error: true + always-publish-from-master: true flatten: true + verbose: true diff --git a/tests/publishers/fixtures/ssh-minimal.xml b/tests/publishers/fixtures/ssh-minimal.xml new file mode 100644 index 000000000..6d277f616 --- /dev/null +++ b/tests/publishers/fixtures/ssh-minimal.xml @@ -0,0 +1,33 @@ + + + + + SSH: + + + + server.example.com + false + + + dest/dir/ + base/source/dir/** + + + false + false + false + + + false + false + + + false + false + false + + + + + diff --git a/tests/publishers/fixtures/ssh-minimal.yaml b/tests/publishers/fixtures/ssh-minimal.yaml new file mode 100644 index 000000000..f06eb4d89 --- /dev/null +++ b/tests/publishers/fixtures/ssh-minimal.yaml @@ -0,0 +1,5 @@ +publishers: + - ssh: + site: 'server.example.com' + target: 'dest/dir/' + source: 'base/source/dir/**'