Fix bug with multiple project-templates

We weren't copying a list we should have.

Change-Id: I18b58d073c9b8f0bd7323a29fb49540d354a0eb2
This commit is contained in:
James E. Blair 2017-09-29 13:44:57 -07:00
parent fe1df19dc5
commit fceaf41130
3 changed files with 58 additions and 1 deletions

View File

@ -0,0 +1,44 @@
- pipeline:
name: check
manager: independent
trigger:
gerrit:
- event: patchset-created
success:
gerrit:
Verified: 1
failure:
gerrit:
Verified: -1
- job:
name: base
parent: null
- job:
name: py27
- project-template:
name: python-jobs
check:
jobs:
- py27
- project-template:
name: python-trusty-jobs
check:
jobs:
- py27:
tags:
- trusty
- project:
name: org/project1
templates:
- python-jobs
- python-trusty-jobs
- project:
name: org/project2
templates:
- python-jobs

View File

@ -4613,6 +4613,17 @@ For CI problems and help debugging, contact ci@example.org"""
self.assertIn('project-test1 : SKIPPED', A.messages[1])
self.assertIn('project-test2 : SKIPPED', A.messages[1])
@simple_layout('layouts/multiple-templates.yaml')
def test_multiple_project_templates(self):
# Test that applying multiple project templates to a project
# doesn't alter them when used for a second project.
A = self.fake_gerrit.addFakeChange('org/project2', 'master', 'A')
self.fake_gerrit.addEvent(A.getPatchsetCreatedEvent(1))
self.waitUntilSettled()
build = self.getJobFromHistory('py27')
self.assertEqual(build.parameters['zuul']['jobtags'], [])
class TestExecutor(ZuulTestCase):
tenant_config_file = 'config/single-tenant/main.yaml'

View File

@ -1030,7 +1030,9 @@ class JobList(object):
if jobname in self.jobs:
self.jobs[jobname].extend(jobs)
else:
self.jobs[jobname] = jobs
# Be sure to make a copy here since this list may be
# modified.
self.jobs[jobname] = jobs[:]
class JobGraph(object):