From e9f554779e7267cdd6c13030e8e3a7e48f44e0b0 Mon Sep 17 00:00:00 2001 From: Daniel Shirley Date: Wed, 16 Jul 2014 22:09:30 +0000 Subject: [PATCH] Added support for JClouds Blobstore JClouds Cloud Storage Settings must be configured for the Jenkins instance. Change-Id: Iaa8bfe363a3c4d9bc5ef7b60aaf4ce25cbf55f6c --- jenkins_jobs/modules/publishers.py | 46 +++++++++++++++++++++++ setup.cfg | 1 + tests/publishers/fixtures/jclouds001.xml | 17 +++++++++ tests/publishers/fixtures/jclouds001.yaml | 6 +++ 4 files changed, 70 insertions(+) create mode 100644 tests/publishers/fixtures/jclouds001.xml create mode 100644 tests/publishers/fixtures/jclouds001.yaml diff --git a/jenkins_jobs/modules/publishers.py b/jenkins_jobs/modules/publishers.py index 2d98f97de..672bad14e 100644 --- a/jenkins_jobs/modules/publishers.py +++ b/jenkins_jobs/modules/publishers.py @@ -100,6 +100,52 @@ def blame_upstream(parser, xml_parent, data): 'BlameUpstreamCommitersPublisher') +def jclouds(parser, xml_parent, data): + """yaml: JClouds Cloud Storage Settings + provides a way to store artifacts on JClouds supported storage providers. + Requires the Jenkins `JClouds Plugin. + `_ + + JClouds Cloud Storage Settings must be configured for the Jenkins instance. + + :arg str profile: preconfigured storage profile (required) + :arg str files: files to upload (regex) (required) + :arg str basedir: the source file path (relative to workspace, Optional) + :arg str container: the destination container name (required) + :arg bool hierarchy: keep hierarchy (default false) + + Example: + + .. literalinclude:: /../../tests/publishers/fixtures/jclouds001.yaml + + """ + + deployer = XML.SubElement(xml_parent, + 'jenkins.plugins.jclouds.blobstore.' + 'BlobStorePublisher') + + if 'profile' not in data: + raise JenkinsJobsException('profile parameter is missing') + XML.SubElement(deployer, 'profileName').text = data.get('profile') + + entries = XML.SubElement(deployer, 'entries') + + deployer_entry = XML.SubElement(entries, + 'jenkins.plugins.jclouds.blobstore.' + 'BlobStoreEntry') + + try: + XML.SubElement(deployer_entry, 'container').text = data['container'] + XML.SubElement(deployer_entry, 'path').text = data.get('basedir', '') + XML.SubElement(deployer_entry, 'sourceFile').text = data['files'] + except KeyError as e: + raise JenkinsJobsException("blobstore requires '%s' to be set" + % e.args[0]) + + XML.SubElement(deployer_entry, 'keepHierarchy').text = str( + data.get('hierarchy', False)).lower() + + def campfire(parser, xml_parent, data): """yaml: campfire Send build notifications to Campfire rooms. diff --git a/setup.cfg b/setup.cfg index a890c7efb..1474b6e72 100644 --- a/setup.cfg +++ b/setup.cfg @@ -152,6 +152,7 @@ jenkins_jobs.publishers = ircbot=jenkins_jobs.modules.publishers:ircbot jabber=jenkins_jobs.modules.publishers:jabber jacoco=jenkins_jobs.modules.publishers:jacoco + jclouds=jenkins_jobs.modules.publishers:jclouds 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/jclouds001.xml b/tests/publishers/fixtures/jclouds001.xml new file mode 100644 index 000000000..b086fa4c6 --- /dev/null +++ b/tests/publishers/fixtures/jclouds001.xml @@ -0,0 +1,17 @@ + + + + + hp + + + jenkins + + *.tar.gz + false + + + + + + diff --git a/tests/publishers/fixtures/jclouds001.yaml b/tests/publishers/fixtures/jclouds001.yaml new file mode 100644 index 000000000..3e6fba166 --- /dev/null +++ b/tests/publishers/fixtures/jclouds001.yaml @@ -0,0 +1,6 @@ +publishers: + - jclouds: + profile: hp + files: '*.tar.gz' + container: jenkins + basedir: