Adds support multijob support to the CopyArtifact plugin

Added the multijob-build keyword support to
CopyArtifact helper and builder

Change-Id: Id657ef072c049fa48d0e0a88bf3dec1a593f67d5
This commit is contained in:
Ari LiVigni 2016-05-31 12:43:33 -04:00
parent 7d13236760
commit 8df564f97c
4 changed files with 45 additions and 4 deletions

View File

@ -96,6 +96,9 @@ def copyartifact(parser, xml_parent, data):
Copy artifact from another project. Requires the :jenkins-wiki:`Copy
Artifact plugin <Copy+Artifact+Plugin>`.
Please note using the multijob-build for which-build argument requires
the :jenkins-wiki:`Multijob plugin <Multijob+Plugin>`
:arg str project: Project to copy from
:arg str filter: what files to copy
:arg str target: Target base directory for copy, blank means use workspace
@ -118,6 +121,7 @@ def copyartifact(parser, xml_parent, data):
* **workspace-latest**
* **build-param**
* **downstream-build**
* **multijob-build**
:arg str build-number: specifies the build number to get when
when specific-build is specified as which-build
@ -151,6 +155,11 @@ def copyartifact(parser, xml_parent, data):
.. literalinclude:: ../../tests/builders/fixtures/copy-artifact001.yaml
:language: yaml
Multijob Example:
.. literalinclude:: ../../tests/builders/fixtures/copy-artifact004.yaml
:language: yaml
"""
t = XML.SubElement(xml_parent, 'hudson.plugins.copyartifact.CopyArtifact')
# Warning: this only works with copy artifact version 1.26+,

View File

@ -197,7 +197,8 @@ def copyartifact_build_selector(xml_parent, data, select_tag='selector'):
'permalink': 'PermalinkBuildSelector',
'workspace-latest': 'WorkspaceSelector',
'build-param': 'ParameterizedBuildSelector',
'downstream-build': 'DownstreamBuildSelector'}
'downstream-build': 'DownstreamBuildSelector',
'multijob-build': 'MultiJobBuildSelector'}
if select not in selectdict:
raise InvalidAttributeError('which-build',
select,
@ -213,9 +214,16 @@ def copyartifact_build_selector(xml_parent, data, select_tag='selector'):
raise InvalidAttributeError('permalink',
permalink,
permalinkdict.keys())
selector = XML.SubElement(xml_parent, select_tag,
{'class': 'hudson.plugins.copyartifact.' +
selectdict[select]})
if select == 'multijob-build':
selector = XML.SubElement(xml_parent, select_tag,
{'class':
'com.tikal.jenkins.plugins.multijob.' +
selectdict[select]})
else:
selector = XML.SubElement(xml_parent, select_tag,
{'class':
'hudson.plugins.copyartifact.' +
selectdict[select]})
if select == 'specific-build':
XML.SubElement(selector, 'buildNumber').text = data['build-number']
if select == 'last-successful':

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<builders>
<hudson.plugins.copyartifact.CopyArtifact>
<project>foo</project>
<filter>*.json</filter>
<target>/home/foo</target>
<flatten>true</flatten>
<optional>true</optional>
<doNotFingerprintArtifacts>false</doNotFingerprintArtifacts>
<parameters>PUBLISH=true</parameters>
<selector class="com.tikal.jenkins.plugins.multijob.MultiJobBuildSelector"/>
</hudson.plugins.copyartifact.CopyArtifact>
</builders>
</project>

View File

@ -0,0 +1,9 @@
builders:
- copyartifact:
project: foo
filter: "*.json"
target: /home/foo
which-build: multijob-build
optional: true
flatten: true
parameter-filters: PUBLISH=true