summaryrefslogtreecommitdiffstats
path: root/jenkins_jobs
diff options
context:
space:
mode:
authorJohn Oram <joram@tutelatechnologies.com>2019-12-13 11:33:21 -0800
committerThanh Ha <zxiiro@gmail.com>2020-01-07 12:41:26 -0500
commitf760f090fcb799e886d5724b41f073adc277af26 (patch)
tree036f625937090768c2380000e9a5803b6510beb3 /jenkins_jobs
parent7b00932d2c4ccd25a269ca6238f90427f3c6ad37 (diff)
downloadpython-jenkins-job-builder-f760f090fcb799e886d5724b41f073adc277af26.tar.gz
python-jenkins-job-builder-f760f090fcb799e886d5724b41f073adc277af26.tar.xz
python-jenkins-job-builder-f760f090fcb799e886d5724b41f073adc277af26.zip
Add support for opsgenie notification plugin
Change-Id: Id84b3d9282568cf47d5feb930fd618afe969b45f
Diffstat (limited to 'jenkins_jobs')
-rwxr-xr-x[-rw-r--r--]jenkins_jobs/modules/publishers.py47
1 files changed, 47 insertions, 0 deletions
diff --git a/jenkins_jobs/modules/publishers.py b/jenkins_jobs/modules/publishers.py
index cf8e938e..98145de7 100644..100755
--- a/jenkins_jobs/modules/publishers.py
+++ b/jenkins_jobs/modules/publishers.py
@@ -1311,6 +1311,53 @@ def ftp_publisher(registry, xml_parent, data):
helpers.convert_mapping_to_xml(ftp, data, mapping, fail_required=True)
+def opsgenie(registry, xml_parent, data):
+ """yaml: opsgenie
+ OpsGenie notification on build completion,
+ Requires the :jenkins-wiki:`OpsGenie Notifier Plugin <OpsGenie+Plugin>`.
+
+ :arg bool enable-sending-alerts: Send alerts to opsgenie. (default false)
+ :arg bool notify-build-start: Send a notification when the build starts. (default false)
+ :arg str api-key: This token is used to verify requests between OpsGenie and Jenkins. You can copy this key from your OpsGenie-Jenkins Integration page. (default '')
+ :arg str tags: Comma-separated list of tags you want to add on alert. (default '')
+ :arg str teams: Comma-separated list of teams that get notified from alert. (default '')
+ :arg str priority: Set the priority of the alert that's going to be created at OpsGenie, if job's build fails. (default 'P3')
+ :arg str build-starts-alerts-priority: Set the priority of the build started alert that's going to be created at OpsGenie. (default 'P3')
+ :arg str api-url: Api url that collects the webhook. (default '')
+
+ Minimal example:
+
+ .. literalinclude::
+ /../../tests/publishers/fixtures/opsgenie-minimal.yaml
+ :language: yaml
+
+ Full Example:
+
+ .. literalinclude::
+ /../../tests/publishers/fixtures/opsgenie-full.yaml
+ :language: yaml
+ """
+
+ mapping = [
+ ("priority", "alertPriority", "P3"),
+ ("build-starts-alerts-priority", "notifyBuildStartPriority", "P3"),
+ ("enable-sending-alerts", "enable", "false"),
+ ("notify-build-start", "notifyBuildStart", "false"),
+ ("api-key", "apiKey", ""),
+ ("api-url", "apiUrl", ""),
+ ("tags", "tags", ""),
+ ("teams", "teams", ""),
+ ]
+
+ opsgenie_notifier = XML.SubElement(
+ xml_parent,
+ "com.opsgenie.integration.jenkins.OpsGenieNotifier",
+ {"plugin": "opsgenie"},
+ )
+
+ helpers.convert_mapping_to_xml(opsgenie_notifier, data, mapping, fail_required=True)
+
+
def rocket(registry, xml_parent, data):
"""yaml: rocket
RocketChat notification on build completion,