diff --git a/jenkins_jobs/modules/publishers.py b/jenkins_jobs/modules/publishers.py index 2367ea48a..9e66c3624 100644 --- a/jenkins_jobs/modules/publishers.py +++ b/jenkins_jobs/modules/publishers.py @@ -2177,8 +2177,10 @@ def copy_to_master(registry, xml_parent, data): :arg list includes: list of file patterns to copy :arg list excludes: list of file patterns to exclude :arg string destination: absolute path into which the files will be copied. - If left blank they will be copied into the - workspace of the current job + If left blank they will be copied into the workspace of the current job + (default '') + :arg bool run-after-result: If this is checked then copying files back to + master will not run until the build result is finalized.(default true) Example: @@ -2186,14 +2188,17 @@ def copy_to_master(registry, xml_parent, data): /../../tests/publishers/fixtures/copy-to-master001.yaml :language: yaml """ - p = 'com.michelin.cio.hudson.plugins.copytoslave.CopyToMasterNotifier' - cm = XML.SubElement(xml_parent, p) + cm = XML.SubElement(xml_parent, 'com.michelin.' + 'cio.hudson.plugins.copytoslave.CopyToMasterNotifier') + cm.set('plugin', 'copy-to-slave') XML.SubElement(cm, 'includes').text = ','.join(data.get('includes', [''])) XML.SubElement(cm, 'excludes').text = ','.join(data.get('excludes', [''])) - - XML.SubElement(cm, 'destinationFolder').text = \ - data.get('destination', '') + mappings = [ + ('run-after-result', 'runAfterResultFinalised', True), + ('destination', 'destinationFolder', '') + ] + helpers.convert_mapping_to_xml(cm, data, mappings, fail_required=True) if data.get('destination', ''): XML.SubElement(cm, 'overrideDestinationFolder').text = 'true' diff --git a/tests/publishers/fixtures/conditional-publisher002.xml b/tests/publishers/fixtures/conditional-publisher002.xml index 99e04662f..006c5e81c 100644 --- a/tests/publishers/fixtures/conditional-publisher002.xml +++ b/tests/publishers/fixtures/conditional-publisher002.xml @@ -8,9 +8,10 @@ ls file* - + file1,file2*.txt file2bad.txt + true @@ -24,4 +25,4 @@ - \ No newline at end of file + diff --git a/tests/publishers/fixtures/copy-to-master001.xml b/tests/publishers/fixtures/copy-to-master001.xml index 1eef06326..18864a5d9 100644 --- a/tests/publishers/fixtures/copy-to-master001.xml +++ b/tests/publishers/fixtures/copy-to-master001.xml @@ -1,9 +1,10 @@ - + file1,file2*.txt file2bad.txt + true