Merge "Add tenant to url formatting." into feature/zuulv3

This commit is contained in:
Jenkins 2017-06-08 15:25:40 +00:00 committed by Gerrit Code Review
commit 9cdcc1a7b8
4 changed files with 9 additions and 3 deletions

View File

@ -29,7 +29,7 @@
github: github:
comment: false comment: false
status: 'success' 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: failure:
github: github:
comment: false comment: false

View File

@ -300,8 +300,8 @@ class TestGithubDriver(ZuulTestCase):
self.assertEqual('tenant-one/reporting', report_status['context']) self.assertEqual('tenant-one/reporting', report_status['context'])
self.assertEqual('success', report_status['state']) self.assertEqual('success', report_status['state'])
self.assertEqual(2, len(A.comments)) self.assertEqual(2, len(A.comments))
report_url = ('http://logs.example.com/reporting/%s/%s/%s/' % report_url = ('http://logs.example.com/tenant-one/reporting/'
(A.project, A.number, A.head_sha)) '%s/%s/%s/' % (A.project, A.number, A.head_sha))
self.assertEqual(report_url, report_status['url']) self.assertEqual(report_url, report_status['url'])
@simple_layout('layouts/merging-github.yaml', driver='github') @simple_layout('layouts/merging-github.yaml', driver='github')

View File

@ -196,6 +196,7 @@ class ExecutorClient(object):
pipeline=pipeline.name, pipeline=pipeline.name,
job=job.name, job=job.name,
project=project, project=project,
tenant=tenant.name,
tags=' '.join(sorted(job.tags))) tags=' '.join(sorted(job.tags)))
if hasattr(item.change, 'branch'): if hasattr(item.change, 'branch'):

View File

@ -1578,11 +1578,13 @@ class QueueItem(object):
# secrets, etc. # secrets, etc.
safe_change = self.change.getSafeAttributes() safe_change = self.change.getSafeAttributes()
safe_pipeline = self.pipeline.getSafeAttributes() safe_pipeline = self.pipeline.getSafeAttributes()
safe_tenant = self.pipeline.layout.tenant.getSafeAttributes()
safe_job = job.getSafeAttributes() if job else {} safe_job = job.getSafeAttributes() if job else {}
safe_build = build.getSafeAttributes() if build else {} safe_build = build.getSafeAttributes() if build else {}
try: try:
url = url_pattern.format(change=safe_change, url = url_pattern.format(change=safe_change,
pipeline=safe_pipeline, pipeline=safe_pipeline,
tenant=safe_tenant,
job=safe_job, job=safe_job,
build=safe_build) build=safe_build)
except KeyError as e: except KeyError as e:
@ -2416,6 +2418,9 @@ class Tenant(object):
self.untrusted_projects.append(project) self.untrusted_projects.append(project)
self._addProject(project) self._addProject(project)
def getSafeAttributes(self):
return Attributes(name=self.name)
class Abide(object): class Abide(object):
def __init__(self): def __init__(self):