From 7dc27e986846560b2d743770dfddd0ee28f987f6 Mon Sep 17 00:00:00 2001 From: Brian Saville Date: Wed, 29 Oct 2014 12:44:51 -0600 Subject: [PATCH] Add doxygen builder support Change-Id: I5ebc0f3708cec121e2e514be1a340c82218d429d --- jenkins_jobs/modules/builders.py | 32 +++++++++++++++++++++++ jenkins_jobs/modules/publishers.py | 31 +++++++++++++++++----- tests/builders/fixtures/doxygen001.xml | 11 ++++++++ tests/builders/fixtures/doxygen001.yaml | 6 +++++ tests/builders/fixtures/doxygen002.xml | 11 ++++++++ tests/builders/fixtures/doxygen002.yaml | 4 +++ tests/publishers/fixtures/doxygen001.xml | 1 + tests/publishers/fixtures/doxygen001.yaml | 3 ++- 8 files changed, 91 insertions(+), 8 deletions(-) create mode 100644 tests/builders/fixtures/doxygen001.xml create mode 100644 tests/builders/fixtures/doxygen001.yaml create mode 100644 tests/builders/fixtures/doxygen002.xml create mode 100644 tests/builders/fixtures/doxygen002.yaml diff --git a/jenkins_jobs/modules/builders.py b/jenkins_jobs/modules/builders.py index fa775a322..78067289a 100644 --- a/jenkins_jobs/modules/builders.py +++ b/jenkins_jobs/modules/builders.py @@ -773,6 +773,38 @@ def artifact_resolver(parser, xml_parent, data): XML.SubElement(ar, 'releaseChecksumPolicy').text = 'warn' +def doxygen(parser, xml_parent, data): + """yaml: doxygen + Builds doxygen HTML documentation. Requires the Jenkins + :jenkins-wiki:`Doxygen plugin `. + + :arg str doxyfile: The doxyfile path (required) + :arg str install: The doxygen installation to use (required) + :arg bool ignore-failure: Keep executing build even on doxygen generation + failure (default false) + :arg bool unstable-warning: Mark the build as unstable if warnings are + generated (default false) + + Example: + + .. literalinclude:: /../../tests/builders/fixtures/doxygen001.yaml + :language: yaml + + """ + doxygen = XML.SubElement(xml_parent, + 'hudson.plugins.doxygen.DoxygenBuilder') + try: + XML.SubElement(doxygen, 'doxyfilePath').text = str(data['doxyfile']) + XML.SubElement(doxygen, 'installationName').text = str(data['install']) + except KeyError as e: + raise MissingAttributeError(e.arg[0]) + + XML.SubElement(doxygen, 'continueOnBuildFailure').text = str( + data.get('ignore-failure', False)).lower() + XML.SubElement(doxygen, 'unstableIfWarnings').text = str( + data.get('unstable-warning', False)).lower() + + def gradle(parser, xml_parent, data): """yaml: gradle Execute gradle tasks. Requires the Jenkins :jenkins-wiki:`Gradle Plugin diff --git a/jenkins_jobs/modules/publishers.py b/jenkins_jobs/modules/publishers.py index 298decc85..14fe00bdc 100644 --- a/jenkins_jobs/modules/publishers.py +++ b/jenkins_jobs/modules/publishers.py @@ -3877,7 +3877,8 @@ def doxygen(parser, xml_parent, data): Requires the Jenkins :jenkins-wiki:`Doxygen Plugin `. :arg str doxyfile: The doxyfile path - :arg bool keepall: Retain doxygen generation for each successful build + :arg str slave: The node or label to pull the doxygen HTML files from + :arg bool keep-all: Retain doxygen generation for each successful build (default: false) :arg str folder: Folder where you run doxygen (default: '') @@ -3886,13 +3887,29 @@ def doxygen(parser, xml_parent, data): .. literalinclude:: /../../tests/publishers/fixtures/doxygen001.yaml :language: yaml """ + + logger = logging.getLogger(__name__) p = XML.SubElement(xml_parent, 'hudson.plugins.doxygen.DoxygenArchiver') - if not data['doxyfile']: - raise JenkinsJobsException("The path to a doxyfile must be specified.") - XML.SubElement(p, 'doxyfilePath').text = str(data.get("doxyfile")) - XML.SubElement(p, 'keepAll').text = str(data.get("keepall", False)).lower() - XML.SubElement(p, 'folderWhereYouRunDoxygen').text = \ - str(data.get("folder", "")) + if not data.get('doxyfile'): + raise JenkinsJobsException('The path to a doxyfile must be specified.') + XML.SubElement(p, 'doxyfilePath').text = str(data.get('doxyfile')) + XML.SubElement(p, 'runOnChild').text = str(data.get('slave', '')) + # backward compatibility + if 'keepall' in data: + if 'keep-all' in data: + XML.SubElement(p, 'keepAll').text = str( + data.get('keep-all', False)).lower() + logger.warn("The value of 'keepall' will be ignored " + "in preference to 'keep-all'.") + else: + XML.SubElement(p, 'keepAll').text = str( + data.get('keepall', False)).lower() + logger.warn("'keepall' is deprecated please use 'keep-all'") + else: + XML.SubElement(p, 'keepAll').text = str( + data.get('keep-all', False)).lower() + XML.SubElement(p, 'folderWhereYouRunDoxygen').text = str( + data.get('folder', '')) def sitemonitor(parser, xml_parent, data): diff --git a/tests/builders/fixtures/doxygen001.xml b/tests/builders/fixtures/doxygen001.xml new file mode 100644 index 000000000..4d9d68b39 --- /dev/null +++ b/tests/builders/fixtures/doxygen001.xml @@ -0,0 +1,11 @@ + + + + + Doxyfile + doxygen + true + true + + + diff --git a/tests/builders/fixtures/doxygen001.yaml b/tests/builders/fixtures/doxygen001.yaml new file mode 100644 index 000000000..e05ec5615 --- /dev/null +++ b/tests/builders/fixtures/doxygen001.yaml @@ -0,0 +1,6 @@ +builders: + - doxygen: + doxyfile: Doxyfile + install: doxygen + ignore-failure: true + unstable-warning: true diff --git a/tests/builders/fixtures/doxygen002.xml b/tests/builders/fixtures/doxygen002.xml new file mode 100644 index 000000000..ed2b1d943 --- /dev/null +++ b/tests/builders/fixtures/doxygen002.xml @@ -0,0 +1,11 @@ + + + + + Doxyfile + doxygen + false + false + + + diff --git a/tests/builders/fixtures/doxygen002.yaml b/tests/builders/fixtures/doxygen002.yaml new file mode 100644 index 000000000..ddfdf1ca4 --- /dev/null +++ b/tests/builders/fixtures/doxygen002.yaml @@ -0,0 +1,4 @@ +builders: + - doxygen: + doxyfile: Doxyfile + install: doxygen diff --git a/tests/publishers/fixtures/doxygen001.xml b/tests/publishers/fixtures/doxygen001.xml index 099e93ef2..56db34eb8 100644 --- a/tests/publishers/fixtures/doxygen001.xml +++ b/tests/publishers/fixtures/doxygen001.xml @@ -3,6 +3,7 @@ Doxyfile + doxygen-slave false build diff --git a/tests/publishers/fixtures/doxygen001.yaml b/tests/publishers/fixtures/doxygen001.yaml index b0be6de3c..4914b7feb 100644 --- a/tests/publishers/fixtures/doxygen001.yaml +++ b/tests/publishers/fixtures/doxygen001.yaml @@ -1,5 +1,6 @@ publishers: - doxygen: doxyfile: "Doxyfile" - keepall: false + slave: "doxygen-slave" + keep-all: false folder: "build"