Fix branch ordering when loading in-repo config
In-repo configs were being loaded from branches in non-deterministic
order. Instead, load from the master branch first, then other branches
in sorted order (so that the order is deterministic).
Also, add an entry to the inheritance path for the job itself, to
improve debugging.
The master is special in that, by being loaded first, jobs that appear
there will be deemed to be the reference definition, which means they
will not have implied branch matchers added. This is what lets us
define jobs in the master branch of zuul-jobs and have them run on
any branch of projects that use them.
The error this fixes caused random branches to contain the reference
definitions of jobs which leads to unpredictable results.
Change-Id: I425395db19cc6b336a2db9cf46415d8a5f4c036f
diff --git a/zuul/configloader.py b/zuul/configloader.py
index cee744d..2cdac38 100644
--- a/zuul/configloader.py
+++ b/zuul/configloader.py
@@ -1374,7 +1374,12 @@
# branch. Remember the branch and then implicitly add a
# branch selector to each job there. This makes the
# in-repo configuration apply only to that branch.
- for branch in project.source.getProjectBranches(project, tenant):
+ branches = sorted(project.source.getProjectBranches(
+ project, tenant))
+ if 'master' in branches:
+ branches.remove('master')
+ branches = ['master'] + branches
+ for branch in branches:
new_project_unparsed_branch_config[project][branch] = \
model.UnparsedTenantConfig()
job = merger.getFiles(
diff --git a/zuul/model.py b/zuul/model.py
index b7c3031..e68e46b 100644
--- a/zuul/model.py
+++ b/zuul/model.py
@@ -888,6 +888,8 @@
return Attributes(name=self.name)
def setRun(self):
+ msg = 'self %s' % (repr(self),)
+ self.inheritance_path = self.inheritance_path + (msg,)
if not self.run:
self.run = self.implied_run