Updating slack publisher parameters

This patch is adding 3 more parameters into the slack publisher which
were added in the Slack Plugin v2.1 and v2.2.

Change-Id: Ief0e0128e7dc9c506aca574cf1550274c318c143
Signed-off-by: Jiri Tyr <jiri.tyr@gmail.com>
This commit is contained in:
Jiri Tyr 2017-07-20 12:28:22 +01:00
parent d53b29169b
commit 69755a0b8d
4 changed files with 35 additions and 9 deletions

View File

@ -6472,10 +6472,14 @@ def slack(registry, xml_parent, data):
Requires the Jenkins :jenkins-wiki:`Slack Plugin <Slack+Plugin>`
When using Slack Plugin version < 2.0, Slack Plugin itself requires a
publisher aswell as properties please note that you have to create those
publisher as well as properties please note that you have to create those
too. When using Slack Plugin version >= 2.0, you should only configure the
publisher.
For backward compatibility, the publisher needs to query version of the
Slack Plugin. Hence the ``query_plugins_info`` parameter shouldn't be set
to ``False`` in the ``jenkins`` section of the configuration file.
:arg str team-domain: Your team's domain at slack. (default '')
:arg str auth-token: The integration token to be used when sending
notifications. (default '')
@ -6510,6 +6514,13 @@ def slack(registry, xml_parent, data):
notification (>=2.0). (default false)
:arg str custom-message: Custom message to be included (>=2.0).
(default '')
:arg str auth-token-credential-id: The ID for the integration token from
the Credentials plugin to be used to send notifications to Slack.
(>=2.1) (default '')
:arg bool bot-user: This option indicates the token belongs to a bot user
in Slack. (>=2.2) (default False)
:arg str base-url: Your Slack compatible Base URL. ``bot-user`` is not
supported with Base URL. (>=2.2) (default '')
Example (version < 2.0):
@ -6559,6 +6570,9 @@ def slack(registry, xml_parent, data):
('commit-info-choice', 'commitInfoChoice', 'NONE'),
('include-custom-message', 'includeCustomMessage', False),
('custom-message', 'customMessage', ''),
('auth-token-credential-id', 'authTokenCredentialId', ''),
('bot-user', 'botUser', False),
('base-url', 'baseUrl', ''),
)
commit_info_choices = ['NONE', 'AUTHORS', 'AUTHORS_AND_TITLES']
@ -6589,17 +6603,20 @@ def slack(registry, xml_parent, data):
value = data.get(yaml_name, default_value)
# 'commit-info-choice' is enumerated type
if yaml_name == 'commit-info-choice':
if value not in commit_info_choices:
raise InvalidAttributeError(
yaml_name, value, commit_info_choices,
)
if (
yaml_name == 'commit-info-choice' and
value not in commit_info_choices):
raise InvalidAttributeError(
yaml_name, value, commit_info_choices,
)
# Ensure that custom-message is set when include-custom-message is set
# to true.
if yaml_name == 'include-custom-message' and data is False:
if not data.get('custom-message', ''):
raise MissingAttributeError('custom-message')
if (
yaml_name == 'include-custom-message' and
data is False and
not data.get('custom-message', '')):
raise MissingAttributeError('custom-message')
_add_xml(slack, xml_name, value)

View File

@ -18,6 +18,9 @@
<commitInfoChoice>NONE</commitInfoChoice>
<includeCustomMessage>false</includeCustomMessage>
<customMessage/>
<authTokenCredentialId/>
<botUser>false</botUser>
<baseUrl/>
</jenkins.plugins.slack.SlackNotifier>
</publishers>
</project>

View File

@ -18,6 +18,9 @@
<commitInfoChoice>AUTHORS_AND_TITLES</commitInfoChoice>
<includeCustomMessage>true</includeCustomMessage>
<customMessage>A custom message.</customMessage>
<authTokenCredentialId>yourauthtoken</authTokenCredentialId>
<botUser>true</botUser>
<baseUrl>https://hooks.slack.com/services/</baseUrl>
</jenkins.plugins.slack.SlackNotifier>
</publishers>
</project>

View File

@ -16,3 +16,6 @@ publishers:
commit-info-choice: 'AUTHORS_AND_TITLES'
include-custom-message: True
custom-message: 'A custom message.'
auth-token-credential-id: yourauthtoken
bot-user: True
base-url: https://hooks.slack.com/services/