diff --git a/tests/fixtures/layout-success-pattern.yaml b/tests/fixtures/layout-success-pattern.yaml new file mode 100644 index 0000000000..cea15f123a --- /dev/null +++ b/tests/fixtures/layout-success-pattern.yaml @@ -0,0 +1,21 @@ +pipelines: + - name: check + manager: IndependentPipelineManager + trigger: + gerrit: + - event: patchset-created + success: + smtp: + to: me@example.org + +jobs: + - name: docs-draft-test + success-pattern: http://docs-draft.example.org/{build.parameters[LOG_PATH]}/publish-docs/ + - name: docs-draft-test2 + success-pattern: http://docs-draft.example.org/{NOPE}/{build.parameters[BAD]}/publish-docs/ + +projects: + - name: org/docs + check: + - docs-draft-test: + - docs-draft-test2 diff --git a/tests/test_scheduler.py b/tests/test_scheduler.py index fe7c7cc4fa..8ac53683b9 100755 --- a/tests/test_scheduler.py +++ b/tests/test_scheduler.py @@ -4392,3 +4392,38 @@ For CI problems and help debugging, contact ci@example.org""" self.assertIn('Build failed.', K.messages[0]) # No more messages reported via smtp self.assertEqual(3, len(self.smtp_messages)) + + def test_success_pattern(self): + "Ensure bad build params are ignored" + + # Use SMTP reporter to grab the result message easier + self.init_repo("org/docs") + self.config.set('zuul', 'layout_config', + 'tests/fixtures/layout-success-pattern.yaml') + self.sched.reconfigure(self.config) + self.worker.hold_jobs_in_build = True + self.registerJobs() + + A = self.fake_gerrit.addFakeChange('org/docs', 'master', 'A') + self.fake_gerrit.addEvent(A.getPatchsetCreatedEvent(1)) + self.waitUntilSettled() + + # Grab build id + self.assertEqual(len(self.builds), 1) + uuid = self.builds[0].unique[:7] + + self.worker.hold_jobs_in_build = False + self.worker.release() + self.waitUntilSettled() + + self.assertEqual(len(self.smtp_messages), 1) + body = self.smtp_messages[0]['body'].splitlines() + self.assertEqual('Build succeeded.', body[0]) + + self.assertIn( + '- docs-draft-test http://docs-draft.example.org/1/1/1/check/' + 'docs-draft-test/%s/publish-docs/' % uuid, + body[2]) + self.assertIn( + '- docs-draft-test2 https://server/job/docs-draft-test2/1/', + body[3]) diff --git a/zuul/reporter/__init__.py b/zuul/reporter/__init__.py index 0569fbe748..0c9a8d8b6b 100644 --- a/zuul/reporter/__init__.py +++ b/zuul/reporter/__init__.py @@ -13,6 +13,7 @@ # under the License. import abc +import logging import six @@ -24,6 +25,8 @@ class BaseReporter(object): Defines the exact public methods that must be supplied. """ + log = logging.getLogger("zuul.reporter.BaseReporter") + def __init__(self, reporter_config={}, sched=None, connection=None): self.reporter_config = reporter_config self.sched = sched