diff --git a/jenkins_jobs/modules/publishers.py b/jenkins_jobs/modules/publishers.py index 37878e554..d6c91ff6a 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 f31989b62..a2da53b55 100644 --- a/setup.cfg +++ b/setup.cfg @@ -153,6 +153,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: