Added support of Office-365-Connections plugin properies configuration

Change-Id: I2108023da57d2d412c0dcca5e513d20fdf059059
Task: #41566
This commit is contained in:
Igor Lakhtenkov 2021-01-13 14:28:04 +03:00
parent 5dd51be6e6
commit 7cb8169c83
5 changed files with 195 additions and 0 deletions

View File

@ -1268,6 +1268,109 @@ def cachet_gating(registry, xml_parent, data):
XML.SubElement(resources, "string").text = str(resource)
def office_365_connector(registry, xml_parent, data):
"""yaml: office-365-connector
Used to send actionable messages to MS Outlook or Teams
Requires the Jenkins: :jenkins-plugins:` Office-365-Connector Plugin
<Office-365-Connector>`.
:arg list webhooks: List of webhooks (required)
* **url** (srt): URL generated in the Office 365 Connectors page (required)
* **name** (str): Allows to provide name fo the connection. Name is not
mandatory but helps managing when there are many connection
assigned to the build (optional, default '')
* **start-notification** (bool): If the notification should be sent on
start of build (optional, default False)
* **notify-success** (bool): If the notification should be sent on
succeeded build (optional, default True)
* **notify-aborted** (bool): If the notification should be sent on
aborted build (optional, default False)
* **notify-not-built** (bool): If the notification should be sent on
not built build (optional, default False)
* **notify-unstable** (bool): If the notification should be sent on
unstable build (optional, default True)
* **notify-failure** (bool): If the notification should be sent on
failed build (optional, default True)
* **notify-back-to-normal** (bool): If the notification should be sent on
back to normal build (optional, default True)
* **notify-repeated-failure** (bool): If the notification should be sent on
repeated failures (optional, default False)
* **timeout** (int): connection timeout (in milliseconds) for TCP and HTTP
(optional, default 30000)
* **macros** (list): List of macros
* **template** (str)
**value** (str)
* **fact-definitions** (list): List of fact definitions
* **name** (str)
**template** (str)
Example:
.. literalinclude:: /../../tests/properties/fixtures/office-365-connector-full.yaml
:language: yaml
"""
office_365_connector = XML.SubElement(
xml_parent, "jenkins.plugins.office365connector.WebhookJobProperty"
)
office_365_connector.set("plugin", "Office-365-Connector")
webhooks = XML.SubElement(office_365_connector, "webhooks")
webhook_mapping = [
("url", "url", None),
("name", "name", ""),
("start-notification", "startNotification", False),
("notify-success", "notifySuccess", True),
("notify-aborted", "notifyAborted", False),
("notify-not-built", "notifyNotBuilt", False),
("notify-unstable", "notifyUnstable", True),
("notify-failure", "notifyFailure", True),
("notify-back-to-normal", "notifyBackToNormal", True),
("notify-repeated-failure", "notifyRepeatedFailure", False),
("timeout", "timeout", 30000),
]
macro_mapping = [("template", "template", None), ("value", "value", None)]
fact_definition_mapping = [("name", "name", None), ("template", "template", None)]
if "webhooks" not in data.keys():
raise MissingAttributeError("webhooks")
for webhook_data in data["webhooks"]:
webhook_element = XML.SubElement(
webhooks, "jenkins.plugins.office365connector.Webhook"
)
helpers.convert_mapping_to_xml(
webhook_element, webhook_data, webhook_mapping, fail_required=True
)
if "macros" in webhook_data.keys():
macros = XML.SubElement(webhook_element, "macros")
for macro_data in webhook_data["macros"]:
macro_element = XML.SubElement(
macros, "jenkins.plugins.office365connector.model.Macro"
)
helpers.convert_mapping_to_xml(
macro_element, macro_data, macro_mapping, fail_required=True
)
if "fact-definitions" in webhook_data.keys():
fact_definitions = XML.SubElement(webhook_element, "factDefinitions")
for fact_definition_data in webhook_data["fact-definitions"]:
fact_definition_element = XML.SubElement(
fact_definitions,
"jenkins.plugins.office365connector.model.FactDefinition",
)
helpers.convert_mapping_to_xml(
fact_definition_element,
fact_definition_data,
fact_definition_mapping,
fail_required=True,
)
def speed_durability(registry, xml_parent, data):
"""yaml: speed-durability
This setting allows users to change the default durability mode

View File

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<properties>
<jenkins.plugins.office365connector.WebhookJobProperty plugin="Office-365-Connector">
<webhooks>
<jenkins.plugins.office365connector.Webhook>
<url>http://outlook.office.com/webhook</url>
<name>full</name>
<startNotification>true</startNotification>
<notifySuccess>false</notifySuccess>
<notifyAborted>true</notifyAborted>
<notifyNotBuilt>true</notifyNotBuilt>
<notifyUnstable>false</notifyUnstable>
<notifyFailure>false</notifyFailure>
<notifyBackToNormal>false</notifyBackToNormal>
<notifyRepeatedFailure>true</notifyRepeatedFailure>
<timeout>30001</timeout>
<macros>
<jenkins.plugins.office365connector.model.Macro>
<template>macro1</template>
<value>macro1_value</value>
</jenkins.plugins.office365connector.model.Macro>
<jenkins.plugins.office365connector.model.Macro>
<template>macro2</template>
<value>macro2_value</value>
</jenkins.plugins.office365connector.model.Macro>
</macros>
<factDefinitions>
<jenkins.plugins.office365connector.model.FactDefinition>
<name>fd1</name>
<template>fd1_value</template>
</jenkins.plugins.office365connector.model.FactDefinition>
<jenkins.plugins.office365connector.model.FactDefinition>
<name>fd2</name>
<template>fd2_value</template>
</jenkins.plugins.office365connector.model.FactDefinition>
</factDefinitions>
</jenkins.plugins.office365connector.Webhook>
</webhooks>
</jenkins.plugins.office365connector.WebhookJobProperty>
</properties>
</project>

View File

@ -0,0 +1,24 @@
properties:
- office-365-connector:
webhooks:
- url: http://outlook.office.com/webhook
name: full
start-notification: true
notify-success: false
notify-aborted: true
notify-not-built: true
notify-unstable: false
notify-failure: false
notify-back-to-normal: false
notify-repeated-failure: true
timeout: 30001
macros:
- template: macro1
value: macro1_value
- template: macro2
value: macro2_value
fact-definitions:
- name: fd1
template: fd1_value
- name: fd2
template: fd2_value

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<properties>
<jenkins.plugins.office365connector.WebhookJobProperty plugin="Office-365-Connector">
<webhooks>
<jenkins.plugins.office365connector.Webhook>
<url>http://outlook.office.com/webhook</url>
<name/>
<startNotification>false</startNotification>
<notifySuccess>true</notifySuccess>
<notifyAborted>false</notifyAborted>
<notifyNotBuilt>false</notifyNotBuilt>
<notifyUnstable>true</notifyUnstable>
<notifyFailure>true</notifyFailure>
<notifyBackToNormal>true</notifyBackToNormal>
<notifyRepeatedFailure>false</notifyRepeatedFailure>
<timeout>30000</timeout>
</jenkins.plugins.office365connector.Webhook>
</webhooks>
</jenkins.plugins.office365connector.WebhookJobProperty>
</properties>
</project>

View File

@ -0,0 +1,4 @@
properties:
- office-365-connector:
webhooks:
- url: http://outlook.office.com/webhook