diff --git a/jenkins_jobs/modules/publishers.py b/jenkins_jobs/modules/publishers.py index cd3b99ffa..4099973b7 100644 --- a/jenkins_jobs/modules/publishers.py +++ b/jenkins_jobs/modules/publishers.py @@ -1175,6 +1175,10 @@ def ftp(registry, xml_parent, data): directories (default false). :arg bool verbose: adds lots of detail useful for debug to the console but generally should be left off (default false) + :arg int retries: the number of times to retry this server in the event of + failure (optional) + :arg int retry-delay: the time to wait, in milliseconds, before attempting + another transfer (default 10000) Minimal Example: @@ -1191,6 +1195,7 @@ def ftp(registry, xml_parent, data): plugin_tag = 'jenkins.plugins.publish__over__ftp.BapFtpPublisherPlugin' publisher_tag = 'jenkins.plugins.publish__over__ftp.BapFtpPublisher' transfer_tag = 'jenkins.plugins.publish__over__ftp.BapFtpTransfer' + retry_tag = 'jenkins.plugins.publish_over_ftp.BapFtpRetry' plugin_reference_tag = 'jenkins.plugins.publish_over_ftp.' \ 'BapFtpPublisherPlugin' (_, transfer_node) = base_publish_over(xml_parent, @@ -1199,6 +1204,7 @@ def ftp(registry, xml_parent, data): plugin_tag, publisher_tag, transfer_tag, + retry_tag, plugin_reference_tag) mapping = [('', 'asciiMode', 'false')] helpers.convert_mapping_to_xml( @@ -1916,6 +1922,10 @@ def ssh(registry, xml_parent, data): directories (default false). :arg bool verbose: adds lots of detail useful for debug to the console but generally should be left off (default false) + :arg int retries: the number of times to retry this server in the event of + failure (optional) + :arg int retry-delay: the time to wait, in milliseconds, before attempting + another transfer (default 10000) Minimal Example: @@ -1931,6 +1941,7 @@ def ssh(registry, xml_parent, data): tag_prefix = 'jenkins.plugins.publish' publisher_tag = '%s__over__ssh.BapSshPublisher' % tag_prefix transfer_tag = '%s__over__ssh.BapSshTransfer' % tag_prefix + retry_tag = '%s_over_ssh.BapSshRetry' % tag_prefix reference_tag = '%s_over_ssh.BapSshPublisherPlugin' % tag_prefix if xml_parent.tag == 'publishers': @@ -1941,7 +1952,8 @@ def ssh(registry, xml_parent, data): is_builder = True base_publish_over(xml_parent, data, console_prefix, plugin_tag, - publisher_tag, transfer_tag, reference_tag, is_builder) + publisher_tag, transfer_tag, retry_tag, reference_tag, + is_builder) def pipeline(registry, xml_parent, data): @@ -2679,8 +2691,8 @@ def groovy_postbuild(registry, xml_parent, data): def base_publish_over(xml_parent, data, console_prefix, plugin_tag, publisher_tag, - transferset_tag, reference_plugin_tag, - is_builder=False): + transferset_tag, retry_tag, + reference_plugin_tag, is_builder=False): outer = XML.SubElement(xml_parent, plugin_tag) # 'Publish over SSH' builder has an extra top delegate element if xml_parent.tag == 'builders' or is_builder: @@ -2721,6 +2733,12 @@ def base_publish_over(xml_parent, data, console_prefix, XML.SubElement(inner, 'useWorkspaceInPromotion').text = 'false' XML.SubElement(inner, 'usePromotionTimestamp').text = 'false' + if 'retries' in data: + retry = XML.SubElement(inner, 'retry', {'class': retry_tag}) + XML.SubElement(retry, 'retries').text = str(data.get('retries', 0)) + XML.SubElement(retry, 'retryDelay').text = str( + data.get('retry-delay', 10000)) + XML.SubElement(delegate, 'continueOnError').text = 'false' XML.SubElement(delegate, 'failOnError').text = str( data.get('fail-on-error', False)).lower() @@ -2753,6 +2771,10 @@ def cifs(registry, xml_parent, data): directories (default false). :arg bool verbose: adds lots of detail useful for debug to the console but generally should be left off (default false) + :arg int retries: the number of times to retry this server in the event of + failure (optional) + :arg int retry-delay: the time to wait, in milliseconds, before attempting + another transfer (default 10000) Minimal Example: @@ -2774,6 +2796,7 @@ def cifs(registry, xml_parent, data): is_builder = True publisher_tag = 'jenkins.plugins.publish__over__cifs.CifsPublisher' transfer_tag = 'jenkins.plugins.publish__over__cifs.CifsTransfer' + retry_tag = 'jenkins.plugins.publish_over_cifs.CifsRetry' plugin_reference_tag = ('jenkins.plugins.publish_over_cifs.' 'CifsPublisherPlugin') base_publish_over(xml_parent, @@ -2782,6 +2805,7 @@ def cifs(registry, xml_parent, data): plugin_tag, publisher_tag, transfer_tag, + retry_tag, plugin_reference_tag, is_builder) diff --git a/tests/publishers/fixtures/cifs-full.xml b/tests/publishers/fixtures/cifs-full.xml index 363348be8..0399fc5e4 100644 --- a/tests/publishers/fixtures/cifs-full.xml +++ b/tests/publishers/fixtures/cifs-full.xml @@ -21,6 +21,10 @@ false false + + 99 + 12345 + false diff --git a/tests/publishers/fixtures/cifs-full.yaml b/tests/publishers/fixtures/cifs-full.yaml index 830e28d19..60af1dbe5 100644 --- a/tests/publishers/fixtures/cifs-full.yaml +++ b/tests/publishers/fixtures/cifs-full.yaml @@ -10,3 +10,5 @@ publishers: fail-on-error: true flatten: true verbose: true + retries: 99 + retry-delay: 12345 diff --git a/tests/publishers/fixtures/ftp-full.xml b/tests/publishers/fixtures/ftp-full.xml index e36cad8be..5b8854c11 100644 --- a/tests/publishers/fixtures/ftp-full.xml +++ b/tests/publishers/fixtures/ftp-full.xml @@ -22,6 +22,10 @@ false false + + 99 + 12345 + false diff --git a/tests/publishers/fixtures/ftp-full.yaml b/tests/publishers/fixtures/ftp-full.yaml index bd6da1854..46a126cd0 100644 --- a/tests/publishers/fixtures/ftp-full.yaml +++ b/tests/publishers/fixtures/ftp-full.yaml @@ -10,3 +10,5 @@ publishers: fail-on-error: true flatten: true verbose: true + retries: 99 + retry-delay: 12345 diff --git a/tests/publishers/fixtures/ssh-full.xml b/tests/publishers/fixtures/ssh-full.xml index 5a5264908..42b97bbdf 100644 --- a/tests/publishers/fixtures/ssh-full.xml +++ b/tests/publishers/fixtures/ssh-full.xml @@ -24,6 +24,10 @@ false false + + 99 + 12345 + false diff --git a/tests/publishers/fixtures/ssh-full.yaml b/tests/publishers/fixtures/ssh-full.yaml index fe6e94a1e..151a49240 100644 --- a/tests/publishers/fixtures/ssh-full.yaml +++ b/tests/publishers/fixtures/ssh-full.yaml @@ -14,3 +14,5 @@ publishers: always-publish-from-master: true flatten: true verbose: true + retries: 99 + retry-delay: 12345