Fix AttributeError when handle periodic job with github driver
Now, if we config periodic pipeline with github driver, the periodic jobs won't be triggered and an AttributeError will be raised. That is because the TimerTriggerEvent object don't have "commits" attribute which is used in the zuul.driver.github.githubconnection.getPushedFileNames method. We don't need the attribute assignment in periodic job, so this change skipp it. Change-Id: Ie1e85cc57ada17eacc44fb084f5f3f17aa8e9c45
This commit is contained in:
parent
ce1bf1f34f
commit
0964278062
|
@ -0,0 +1,25 @@
|
|||
- pipeline:
|
||||
name: periodic
|
||||
manager: independent
|
||||
trigger:
|
||||
timer:
|
||||
- time: '* * * * * */1'
|
||||
|
||||
- job:
|
||||
name: base
|
||||
parent: null
|
||||
run: playbooks/base.yaml
|
||||
|
||||
- job:
|
||||
name: project-bitrot
|
||||
nodeset:
|
||||
nodes:
|
||||
- name: static
|
||||
label: ubuntu-xenial
|
||||
run: playbooks/project-bitrot.yaml
|
||||
|
||||
- project:
|
||||
name: org/project
|
||||
periodic:
|
||||
jobs:
|
||||
- project-bitrot
|
|
@ -210,6 +210,34 @@ class TestGithubDriver(ZuulTestCase):
|
|||
self.waitUntilSettled()
|
||||
self.assertEqual(1, len(self.history))
|
||||
|
||||
@simple_layout('layouts/basic-github.yaml', driver='github')
|
||||
def test_timer_event(self):
|
||||
self.executor_server.hold_jobs_in_build = True
|
||||
self.commitConfigUpdate('org/common-config',
|
||||
'layouts/timer-github.yaml')
|
||||
self.sched.reconfigure(self.config)
|
||||
time.sleep(2)
|
||||
self.waitUntilSettled()
|
||||
self.assertEqual(len(self.builds), 1)
|
||||
self.executor_server.hold_jobs_in_build = False
|
||||
# Stop queuing timer triggered jobs so that the assertions
|
||||
# below don't race against more jobs being queued.
|
||||
self.commitConfigUpdate('org/common-config',
|
||||
'layouts/basic-github.yaml')
|
||||
self.sched.reconfigure(self.config)
|
||||
self.waitUntilSettled()
|
||||
# If APScheduler is in mid-event when we remove the job, we
|
||||
# can end up with one more event firing, so give it an extra
|
||||
# second to settle.
|
||||
time.sleep(1)
|
||||
self.waitUntilSettled()
|
||||
self.executor_server.release()
|
||||
self.waitUntilSettled()
|
||||
self.assertHistory([
|
||||
dict(name='project-bitrot', result='SUCCESS',
|
||||
ref='refs/heads/master'),
|
||||
], ordered=False)
|
||||
|
||||
@simple_layout('layouts/dequeue-github.yaml', driver='github')
|
||||
def test_dequeue_pull_synchronized(self):
|
||||
self.executor_server.hold_jobs_in_build = True
|
||||
|
|
|
@ -721,7 +721,8 @@ class GithubConnection(BaseConnection):
|
|||
change.newrev = event.newrev
|
||||
change.url = self.getGitwebUrl(project, sha=event.newrev)
|
||||
change.source_event = event
|
||||
change.files = self.getPushedFileNames(event)
|
||||
if hasattr(event, 'commits'):
|
||||
change.files = self.getPushedFileNames(event)
|
||||
return change
|
||||
|
||||
def _getChange(self, project, number, patchset=None, refresh=False):
|
||||
|
|
Loading…
Reference in New Issue