From 97cdaa8114ec430b105cd80227ca6d4590467443 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Fri, 24 Jan 2014 13:56:35 +0100 Subject: [PATCH] Support site monitor publisher This publisher allows to check an URL after the build steps. It requires the sitemonitor plugin from https://wiki.jenkins-ci.org/display/JENKINS/SiteMonitor+Plugin Change-Id: I83026e4db9bd7975a34b7d8e015a4a73c3b09ae8 --- jenkins_jobs/modules/publishers.py | 24 +++++++++++++++++++ setup.py | 1 + tests/publishers/fixtures/sitemonitor001.xml | 15 ++++++++++++ tests/publishers/fixtures/sitemonitor001.yaml | 5 ++++ 4 files changed, 45 insertions(+) create mode 100644 tests/publishers/fixtures/sitemonitor001.xml create mode 100644 tests/publishers/fixtures/sitemonitor001.yaml diff --git a/jenkins_jobs/modules/publishers.py b/jenkins_jobs/modules/publishers.py index 8d89ffd66..7f35066f7 100644 --- a/jenkins_jobs/modules/publishers.py +++ b/jenkins_jobs/modules/publishers.py @@ -3113,6 +3113,30 @@ def description_setter(parser, xml_parent, data): XML.SubElement(descriptionsetter, 'setForMatrix').text = for_matrix +def sitemonitor(parser, xml_parent, data): + """yaml: sitemonitor + This plugin checks the availability of an url. + + It requires the `sitemonitor plugin. + `_ + + :arg list sites: List of URLs to check + + Example: + + .. literalinclude:: /../../tests/publishers/fixtures/sitemonitor001.yaml + + """ + mon = XML.SubElement(xml_parent, + 'hudson.plugins.sitemonitor.SiteMonitorRecorder') + if data.get('sites'): + sites = XML.SubElement(mon, 'mSites') + for siteurl in data.get('sites'): + site = XML.SubElement(sites, + 'hudson.plugins.sitemonitor.model.Site') + XML.SubElement(site, 'mUrl').text = siteurl['url'] + + class Publishers(jenkins_jobs.modules.base.Base): sequence = 70 diff --git a/setup.py b/setup.py index f14a9a510..978c84db6 100644 --- a/setup.py +++ b/setup.py @@ -152,6 +152,7 @@ setuptools.setup( 'junit=jenkins_jobs.modules.publishers:junit', 'logparser=jenkins_jobs.modules.publishers:logparser', 'maven-deploy=jenkins_jobs.modules.publishers:maven_deploy', + 'sitemonitor=jenkins_jobs.modules.publishers:sitemonitor', 'performance=jenkins_jobs.modules.publishers:performance', 'pipeline=jenkins_jobs.modules.publishers:pipeline', 'plot=jenkins_jobs.modules.publishers:plot', diff --git a/tests/publishers/fixtures/sitemonitor001.xml b/tests/publishers/fixtures/sitemonitor001.xml new file mode 100644 index 000000000..812cfb84f --- /dev/null +++ b/tests/publishers/fixtures/sitemonitor001.xml @@ -0,0 +1,15 @@ + + + + + + + http://foo.example.com + + + http://bar.example.com:8080/ + + + + + diff --git a/tests/publishers/fixtures/sitemonitor001.yaml b/tests/publishers/fixtures/sitemonitor001.yaml new file mode 100644 index 000000000..f0595d5f7 --- /dev/null +++ b/tests/publishers/fixtures/sitemonitor001.yaml @@ -0,0 +1,5 @@ +publishers: + - sitemonitor: + sites: + - url: http://foo.example.com + - url: http://bar.example.com:8080/