diff --git a/jenkins_jobs/modules/publishers.py b/jenkins_jobs/modules/publishers.py index 2558447de..a23146e28 100644 --- a/jenkins_jobs/modules/publishers.py +++ b/jenkins_jobs/modules/publishers.py @@ -2874,6 +2874,40 @@ def build_publisher(parser, xml_parent, data): str(data.get('artifact-num-to-keep', -1)) +def stash(parser, xml_parent, data): + """yaml: stash + This plugin will configure the Jenkins Stash Notifier plugin to + notify Atlassian Stash after job completes. + + Requires the Jenkins `StashNotifier Plugin. + <https://wiki.jenkins-ci.org/display/JENKINS/StashNotifier+Plugin>`_ + + :arg string url: Base url of Stash Server (Default: "") + :arg string username: Username of Stash Server (Default: "") + :arg string password: Password of Stash Server (Default: "") + :arg bool ignore-ssl: Ignore unverified SSL certificate (Default: False) + :arg string commit-sha1: Commit SHA1 to notify (Default: "") + :arg bool include-build-number: Include build number in key + (Default: False) + + Example: + + .. literalinclude:: ../../tests/publishers/fixtures/stash001.yaml + """ + + top = XML.SubElement(xml_parent, + 'org.jenkinsci.plugins.stashNotifier.StashNotifier') + + XML.SubElement(top, 'stashServerBaseUrl').text = data.get('url', '') + XML.SubElement(top, 'stashUserName').text = data.get('username', '') + XML.SubElement(top, 'stashUserPassword').text = data.get('password', '') + 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() + + class Publishers(jenkins_jobs.modules.base.Base): sequence = 70 diff --git a/setup.py b/setup.py index c3797bf94..4c51e4c2d 100644 --- a/setup.py +++ b/setup.py @@ -155,6 +155,7 @@ setuptools.setup( 'sloccount=jenkins_jobs.modules.publishers:sloccount', 'sonar=jenkins_jobs.modules.publishers:sonar', 'ssh=jenkins_jobs.modules.publishers:ssh', + 'stash=jenkins_jobs.modules.publishers:stash', 'tap=jenkins_jobs.modules.publishers:tap', 'text-finder=jenkins_jobs.modules.publishers:text_finder', 'trigger=jenkins_jobs.modules.publishers:trigger', diff --git a/tests/publishers/fixtures/stash001.xml b/tests/publishers/fixtures/stash001.xml new file mode 100644 index 000000000..9260c6412 --- /dev/null +++ b/tests/publishers/fixtures/stash001.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" ?> +<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/stash001.yaml b/tests/publishers/fixtures/stash001.yaml new file mode 100644 index 000000000..bfb734c0d --- /dev/null +++ b/tests/publishers/fixtures/stash001.yaml @@ -0,0 +1,8 @@ +publishers: + - stash: + url: "https://mystash" + username: a + password: b + ignore-ssl: true + commit-sha1: c + include-build-number: true