Merge "Add tenant to url formatting." into feature/zuulv3
diff --git a/tests/fixtures/layouts/reporting-github.yaml b/tests/fixtures/layouts/reporting-github.yaml
index 8dd35b0..43e71c7 100644
--- a/tests/fixtures/layouts/reporting-github.yaml
+++ b/tests/fixtures/layouts/reporting-github.yaml
@@ -29,7 +29,7 @@
       github:
         comment: false
         status: 'success'
-        status-url: http://logs.example.com/{pipeline.name}/{change.project}/{change.number}/{change.patchset}/
+        status-url: http://logs.example.com/{tenant.name}/{pipeline.name}/{change.project}/{change.number}/{change.patchset}/
     failure:
       github:
         comment: false
diff --git a/tests/unit/test_github_driver.py b/tests/unit/test_github_driver.py
index 2013ee0..3382bc1 100644
--- a/tests/unit/test_github_driver.py
+++ b/tests/unit/test_github_driver.py
@@ -300,8 +300,8 @@
         self.assertEqual('tenant-one/reporting', report_status['context'])
         self.assertEqual('success', report_status['state'])
         self.assertEqual(2, len(A.comments))
-        report_url = ('http://logs.example.com/reporting/%s/%s/%s/' %
-                      (A.project, A.number, A.head_sha))
+        report_url = ('http://logs.example.com/tenant-one/reporting/'
+                      '%s/%s/%s/' % (A.project, A.number, A.head_sha))
         self.assertEqual(report_url, report_status['url'])
 
     @simple_layout('layouts/merging-github.yaml', driver='github')
diff --git a/zuul/executor/client.py b/zuul/executor/client.py
index cf8d973..b7e5a45 100644
--- a/zuul/executor/client.py
+++ b/zuul/executor/client.py
@@ -196,6 +196,7 @@
                            pipeline=pipeline.name,
                            job=job.name,
                            project=project,
+                           tenant=tenant.name,
                            tags=' '.join(sorted(job.tags)))
 
         if hasattr(item.change, 'branch'):
diff --git a/zuul/model.py b/zuul/model.py
index 1bd077b..5427094 100644
--- a/zuul/model.py
+++ b/zuul/model.py
@@ -1578,11 +1578,13 @@
         # secrets, etc.
         safe_change = self.change.getSafeAttributes()
         safe_pipeline = self.pipeline.getSafeAttributes()
+        safe_tenant = self.pipeline.layout.tenant.getSafeAttributes()
         safe_job = job.getSafeAttributes() if job else {}
         safe_build = build.getSafeAttributes() if build else {}
         try:
             url = url_pattern.format(change=safe_change,
                                      pipeline=safe_pipeline,
+                                     tenant=safe_tenant,
                                      job=safe_job,
                                      build=safe_build)
         except KeyError as e:
@@ -2416,6 +2418,9 @@
         self.untrusted_projects.append(project)
         self._addProject(project)
 
+    def getSafeAttributes(self):
+        return Attributes(name=self.name)
+
 
 class Abide(object):
     def __init__(self):