diff --git a/jenkins_jobs/modules/publishers.py b/jenkins_jobs/modules/publishers.py index b8a085d09..24167080d 100644 --- a/jenkins_jobs/modules/publishers.py +++ b/jenkins_jobs/modules/publishers.py @@ -4417,9 +4417,14 @@ def stash(registry, xml_parent, data): :arg bool include-build-number: Include build number in key (default false) - Example: + Minimal Example: - .. literalinclude:: /../../tests/publishers/fixtures/stash001.yaml + .. literalinclude:: /../../tests/publishers/fixtures/stash-minimal.yaml + :language: yaml + + Full Example: + + .. literalinclude:: /../../tests/publishers/fixtures/stash-full.yaml :language: yaml """ top = XML.SubElement(xml_parent, @@ -4436,12 +4441,13 @@ def stash(registry, xml_parent, data): XML.SubElement(top, 'stashUserPassword' ).text = helpers.get_value_from_yaml_or_config_file( 'password', 'stash', data, registry.jjb_config) - - XML.SubElement(top, 'ignoreUnverifiedSSLPeer').text = str( - data.get('ignore-ssl', False)).lower() - XML.SubElement(top, 'commitSha1').text = data.get('commit-sha1', '') - XML.SubElement(top, 'includeBuildNumberInKey').text = str( - data.get('include-build-number', False)).lower() + mappings = [ + ('ignore-ssl', 'ignoreUnverifiedSSLPeer', False), + ('commit-sha1', 'commitSha1', ''), + ('include-build-number', 'includeBuildNumberInKey', False) + ] + helpers.convert_mapping_to_xml( + top, data, mappings, fail_required=True) def dependency_check(registry, xml_parent, data): diff --git a/tests/publishers/fixtures/stash-full.xml b/tests/publishers/fixtures/stash-full.xml new file mode 100644 index 000000000..a07da18aa --- /dev/null +++ b/tests/publishers/fixtures/stash-full.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8"?> +<project> + <publishers> + <org.jenkinsci.plugins.stashNotifier.StashNotifier> + <stashServerBaseUrl>https://mystash</stashServerBaseUrl> + <stashUserName>a</stashUserName> + <stashUserPassword>b</stashUserPassword> + <ignoreUnverifiedSSLPeer>true</ignoreUnverifiedSSLPeer> + <commitSha1>c</commitSha1> + <includeBuildNumberInKey>true</includeBuildNumberInKey> + </org.jenkinsci.plugins.stashNotifier.StashNotifier> + </publishers> +</project> diff --git a/tests/publishers/fixtures/stash-full.yaml b/tests/publishers/fixtures/stash-full.yaml new file mode 100644 index 000000000..bfb734c0d --- /dev/null +++ b/tests/publishers/fixtures/stash-full.yaml @@ -0,0 +1,8 @@ +publishers: + - stash: + url: "https://mystash" + username: a + password: b + ignore-ssl: true + commit-sha1: c + include-build-number: true diff --git a/tests/publishers/fixtures/stash-minimal.xml b/tests/publishers/fixtures/stash-minimal.xml new file mode 100644 index 000000000..2cee1daab --- /dev/null +++ b/tests/publishers/fixtures/stash-minimal.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8"?> +<project> + <publishers> + <org.jenkinsci.plugins.stashNotifier.StashNotifier> + <stashServerBaseUrl/> + <stashUserName/> + <stashUserPassword/> + <ignoreUnverifiedSSLPeer>false</ignoreUnverifiedSSLPeer> + <commitSha1/> + <includeBuildNumberInKey>false</includeBuildNumberInKey> + </org.jenkinsci.plugins.stashNotifier.StashNotifier> + </publishers> +</project> diff --git a/tests/publishers/fixtures/stash-minimal.yaml b/tests/publishers/fixtures/stash-minimal.yaml new file mode 100644 index 000000000..b9680ce9d --- /dev/null +++ b/tests/publishers/fixtures/stash-minimal.yaml @@ -0,0 +1,2 @@ +publishers: + - stash