Make it possible to configure job retries with zuul_return
Change-Id: Ie209b6e9a4b9192f4e53e73022d4549611cd230c
This commit is contained in:
parent
463cd1615b
commit
98bda7c3e3
|
@ -1088,6 +1088,21 @@ For example:
|
|||
pause: true
|
||||
registry_ip_address: "{{ hostvars[groups.all[0]].ansible_host }}"
|
||||
|
||||
Skipping retries
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
It's possible to skip the retry caused by a failure in ``pre-run``
|
||||
by setting **zuul.retry** to ``false``.
|
||||
|
||||
For example the following would skip retrying the build:
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
tasks:
|
||||
- zuul_return:
|
||||
data:
|
||||
zuul:
|
||||
retry: false
|
||||
|
||||
.. _build_status:
|
||||
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
---
|
||||
features:
|
||||
- |
|
||||
It is now possible for jobs to skip retries caused by failures in
|
||||
'pre-run' by returning `retry: false`:
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
- zuul_return:
|
||||
data:
|
||||
zuul:
|
||||
retry: false
|
|
@ -0,0 +1,2 @@
|
|||
- hosts: localhost
|
||||
tasks: []
|
7
tests/fixtures/config/data-return/git/common-config/playbooks/skip-retry-return.yaml
vendored
Normal file
7
tests/fixtures/config/data-return/git/common-config/playbooks/skip-retry-return.yaml
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
- hosts: localhost
|
||||
tasks:
|
||||
- zuul_return:
|
||||
data:
|
||||
zuul:
|
||||
retry: false
|
||||
failed_when: true
|
|
@ -120,6 +120,11 @@
|
|||
parent: several-zuul-return-parent
|
||||
run: playbooks/several-zuul-return-child.yaml
|
||||
|
||||
- job:
|
||||
name: skip-retry-return
|
||||
pre-run: playbooks/skip-retry-return.yaml
|
||||
run: playbooks/pass.yaml
|
||||
|
||||
- project:
|
||||
name: org/project
|
||||
check:
|
||||
|
@ -224,3 +229,9 @@
|
|||
soft: true
|
||||
- name: data-return-c
|
||||
soft: true
|
||||
|
||||
- project:
|
||||
name: org/project-skip-retry
|
||||
check:
|
||||
jobs:
|
||||
- skip-retry-return
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
test
|
|
@ -14,3 +14,4 @@
|
|||
- org/project6
|
||||
- org/project7
|
||||
- org/project-soft
|
||||
- org/project-skip-retry
|
||||
|
|
|
@ -4928,6 +4928,19 @@ class TestDataReturn(AnsibleZuulTestCase):
|
|||
self.assertTrue(re.search('data-return .* SKIPPED', A.messages[-1]))
|
||||
self.assertIn('Build succeeded', A.messages[-1])
|
||||
|
||||
def test_data_return_skip_retry(self):
|
||||
A = self.fake_gerrit.addFakeChange(
|
||||
'org/project-skip-retry',
|
||||
'master',
|
||||
'A'
|
||||
)
|
||||
self.fake_gerrit.addEvent(A.getPatchsetCreatedEvent(1))
|
||||
self.waitUntilSettled()
|
||||
self.assertHistory([
|
||||
dict(name='skip-retry-return', result='FAILURE',
|
||||
changes='1,1'),
|
||||
])
|
||||
|
||||
def test_data_return_child_jobs_failure(self):
|
||||
A = self.fake_gerrit.addFakeChange('org/project5', 'master', 'A')
|
||||
self.fake_gerrit.addEvent(A.getPatchsetCreatedEvent(1))
|
||||
|
|
|
@ -56,6 +56,7 @@ def merge_data(dict_a, dict_b):
|
|||
artifacts = merge_zuul_list(dict_a, dict_b, 'artifacts')
|
||||
file_comments = merge_file_comments(dict_a, dict_b)
|
||||
warnings = merge_zuul_list(dict_a, dict_b, 'warnings')
|
||||
retry = dict_a.get('zuul', {}).get('retry')
|
||||
merge_dict(dict_a, dict_b)
|
||||
if artifacts:
|
||||
dict_b.setdefault('zuul', {})['artifacts'] = artifacts
|
||||
|
@ -63,6 +64,9 @@ def merge_data(dict_a, dict_b):
|
|||
dict_b.setdefault("zuul", {})["file_comments"] = file_comments
|
||||
if warnings:
|
||||
dict_b.setdefault('zuul', {})['warnings'] = warnings
|
||||
if retry:
|
||||
dict_b.setdefault('zuul', {})['retry'] = retry
|
||||
|
||||
return dict_b
|
||||
|
||||
|
||||
|
|
|
@ -1829,6 +1829,11 @@ class AnsibleJob(object):
|
|||
if run_unreachable or post_unreachable:
|
||||
return None
|
||||
|
||||
# Report a failure if pre-run failed and the user reported to
|
||||
# zuul that the job should not retry.
|
||||
if result_data.get('zuul', {}).get('retry') is False and not result:
|
||||
result = "FAILURE"
|
||||
|
||||
return result
|
||||
|
||||
def runCleanupPlaybooks(self, success):
|
||||
|
|
Loading…
Reference in New Issue