Merge "Fix implicit role for repos named ansible"

This commit is contained in:
Zuul 2018-04-20 23:33:59 +00:00 committed by Gerrit Code Review
commit 0101a37c18
6 changed files with 27 additions and 1 deletions

View File

@ -0,0 +1,8 @@
- job:
name: hello-ansible
run: playbooks/hello-ansible.yaml
- project:
check:
jobs:
- hello-ansible

View File

@ -0,0 +1 @@
test

View File

@ -0,0 +1,5 @@
- hosts: all
tasks:
- name: hello
debug:
msg: hello ansible

View File

@ -8,3 +8,4 @@
- org/project
- org/plugin-project
- bare-role
- org/ansible

View File

@ -2109,6 +2109,17 @@ class TestAnsible(AnsibleZuulTestCase):
self.assertIn(fail.format("timeout", build_timeout.uuid), msg)
self.assertIn(fail.format("failpost", build_failpost.uuid), msg)
def test_repo_ansible(self):
A = self.fake_gerrit.addFakeChange('org/ansible', 'master', 'A')
self.fake_gerrit.addEvent(A.getPatchsetCreatedEvent(1))
self.waitUntilSettled()
self.assertEqual(A.reported, 1,
"A should report success")
self.assertHistory([
dict(name='hello-ansible', result='SUCCESS', changes='1,1'),
])
def _add_job(self, job_name):
conf = textwrap.dedent(
"""

View File

@ -810,7 +810,7 @@ class JobParser(object):
def _makeImplicitRole(self, job):
project = job.source_context.project
name = project.name.split('/')[-1]
name = JobParser.ANSIBLE_ROLE_RE.sub('', name)
name = JobParser.ANSIBLE_ROLE_RE.sub('', name) or name
return model.ZuulRole(name,
project.canonical_name,
implicit=True)