Merge "Add zuul.child_jobs in ansible inventory file"

This commit is contained in:
Zuul 2018-07-11 06:34:20 +00:00 committed by Gerrit Code Review
commit 3b652abae1
6 changed files with 28 additions and 4 deletions

View File

@ -175,6 +175,11 @@ of item.
configuration of items ahead in a dependent pipeline changes,
Zuul creates a new buildset and restarts all of the jobs.
.. var:: child_jobs
A list of the first level child jobs to be run after this job
has finished successfully.
.. var:: ref
The git ref of the item. This will be the full path (e.g.,

View File

@ -0,0 +1,6 @@
---
features:
- |
A new Ansible inventory variable :var:`zuul.child_jobs` which is a
list of the first level child jobs to be run after a job has
finished successfully.

View File

@ -8,6 +8,13 @@
- nodepool.region == 'test-region'
- nodepool.provider == 'test-provider'
- name: Assert zuul variables are valid.
assert:
that:
- zuul.child_jobs is defined
- zuul.child_jobs|length == 1
- "'check-hostvars' in zuul.child_jobs"
- name: Assert zuul-executor variables are valid.
assert:
that:

View File

@ -15,8 +15,12 @@
- python27
- faillocal
- check-vars
- check-hostvars
- check-secret-names
- check-hostvars:
dependencies:
- check-vars
- check-secret-names:
dependencies:
- check-hostvars
- timeout
- post-timeout
- hello-world

View File

@ -182,6 +182,8 @@ class ExecutorClient(object):
zuul_params['newrev'] = item.change.newrev
zuul_params['projects'] = {} # Set below
zuul_params['items'] = dependent_changes
zuul_params['child_jobs'] = list(item.job_graph.getDirectDependentJobs(
job.name))
params = dict()
params['job'] = job.name

View File

@ -1397,7 +1397,7 @@ class JobGraph(object):
def getJobs(self):
return list(self.jobs.values()) # Report in the order of layout cfg
def _getDirectDependentJobs(self, parent_job):
def getDirectDependentJobs(self, parent_job):
ret = set()
for dependent_name, parent_names in self._dependencies.items():
if parent_job in parent_names:
@ -1409,7 +1409,7 @@ class JobGraph(object):
jobs_to_iterate = set([parent_job])
while len(jobs_to_iterate) > 0:
current_job = jobs_to_iterate.pop()
current_dependent_jobs = self._getDirectDependentJobs(current_job)
current_dependent_jobs = self.getDirectDependentJobs(current_job)
new_dependent_jobs = current_dependent_jobs - all_dependent_jobs
jobs_to_iterate |= new_dependent_jobs
all_dependent_jobs |= new_dependent_jobs