From 2331f4c86a9c2fae34a2e0590fccf6aa518ded60 Mon Sep 17 00:00:00 2001
From: Adam Kaufman <kaufman.blue@gmail.com>
Date: Tue, 14 Jul 2015 08:14:49 -0400
Subject: [PATCH] added support for jdepend plugin

Change-Id: I6540b0238ebdad0b0763d596586e2e8702af7599
---
 jenkins_jobs/modules/publishers.py        | 21 +++++++++++++++++++++
 setup.cfg                                 |  1 +
 tests/publishers/fixtures/jdepend001.xml  |  8 ++++++++
 tests/publishers/fixtures/jdepend001.yaml |  3 +++
 4 files changed, 33 insertions(+)
 create mode 100644 tests/publishers/fixtures/jdepend001.xml
 create mode 100644 tests/publishers/fixtures/jdepend001.yaml

diff --git a/jenkins_jobs/modules/publishers.py b/jenkins_jobs/modules/publishers.py
index 3c4b05846..db4625f12 100644
--- a/jenkins_jobs/modules/publishers.py
+++ b/jenkins_jobs/modules/publishers.py
@@ -176,6 +176,27 @@ def javadoc(parser, xml_parent, data):
         'keep-all-successful', False)).lower()
 
 
+def jdepend(parser, xml_parent, data):
+    """yaml: jdepend
+    Publish jdepend report
+    Requires the :jenkins-wiki:`JDepend Plugin<JDepend+Plugin>`.
+
+    :arg str file: path to jdepend file (required)
+
+    Example:
+
+    .. literalinclude::  /../../tests/publishers/fixtures/jdepend001.yaml
+       :language: yaml
+    """
+    jdepend = XML.SubElement(
+        xml_parent,
+        'hudson.plugins.jdepend.JDependRecorder')
+    filepath = data.get('file', None)
+    if filepath is None:
+        raise MissingAttributeError('file')
+    XML.SubElement(jdepend, 'configuredJDependFile').text = str(filepath)
+
+
 def campfire(parser, xml_parent, data):
     """yaml: campfire
     Send build notifications to Campfire rooms.
diff --git a/setup.cfg b/setup.cfg
index 796c0a7a7..095e110b0 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -173,6 +173,7 @@ jenkins_jobs.publishers =
     jacoco=jenkins_jobs.modules.publishers:jacoco
     javadoc=jenkins_jobs.modules.publishers:javadoc
     jclouds=jenkins_jobs.modules.publishers:jclouds
+    jdepend=jenkins_jobs.modules.publishers:jdepend
     jira=jenkins_jobs.modules.publishers:jira
     join-trigger=jenkins_jobs.modules.publishers:join_trigger
     junit=jenkins_jobs.modules.publishers:junit
diff --git a/tests/publishers/fixtures/jdepend001.xml b/tests/publishers/fixtures/jdepend001.xml
new file mode 100644
index 000000000..630024ff0
--- /dev/null
+++ b/tests/publishers/fixtures/jdepend001.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<project>
+  <publishers>
+    <hudson.plugins.jdepend.JDependRecorder>
+      <configuredJDependFile>build/jdepend/main.xml</configuredJDependFile>
+    </hudson.plugins.jdepend.JDependRecorder>
+  </publishers>
+</project>
diff --git a/tests/publishers/fixtures/jdepend001.yaml b/tests/publishers/fixtures/jdepend001.yaml
new file mode 100644
index 000000000..e90050863
--- /dev/null
+++ b/tests/publishers/fixtures/jdepend001.yaml
@@ -0,0 +1,3 @@
+publishers:
+  - jdepend:
+      file: build/jdepend/main.xml