chore(reporters): make it 3.11+ (and 4.0) compatible!
Signed-off-by: Raito Bezarius <masterancpp@gmail.com>
This commit is contained in:
parent
8a1b11f8b1
commit
4a85b5d56b
|
@ -18,6 +18,8 @@ from buildbot.www.auth import AuthBase
|
|||
from buildbot.www.oauth2 import OAuth2Auth
|
||||
from buildbot.changes.gerritchangesource import GerritChangeSource
|
||||
from buildbot.reporters.utils import getURLForBuildrequest
|
||||
from buildbot.reporters.generators.build import BuildStatusGenerator
|
||||
from buildbot.reporters.message import MessageFormatterFunction
|
||||
from buildbot.process.buildstep import EXCEPTION
|
||||
from buildbot.process.buildstep import SUCCESS
|
||||
from buildbot.process.results import worst_status
|
||||
|
@ -698,7 +700,20 @@ class PeriodicWithStartup(schedulers.Periodic):
|
|||
yield self.setState("last_build", None)
|
||||
yield super().activate()
|
||||
|
||||
def gerritReviewCB(builderName, build, result, master, arg):
|
||||
def gerritReviewFmt(url, data):
|
||||
if 'build' not in data:
|
||||
raise ValueError('`build` is supposed to be present to format a build')
|
||||
|
||||
build = data['build']
|
||||
if 'builder' not in build and 'name' not in build['builder']:
|
||||
raise ValueError('either `builder` or `builder.name` is not present in the build dictionary, unexpected format request')
|
||||
|
||||
builderName = build['builder']['name']
|
||||
|
||||
if len(build['results']) != 1:
|
||||
raise ValueError('this review request contains more than one build results, unexpected format request')
|
||||
|
||||
result = build['results'][0]
|
||||
if result == util.RETRY:
|
||||
return dict()
|
||||
|
||||
|
@ -723,7 +738,7 @@ def gerritReviewCB(builderName, build, result, master, arg):
|
|||
message += f" (see {', '.join(urls)})"
|
||||
message += "\n"
|
||||
|
||||
if arg:
|
||||
if url:
|
||||
message += "\nFor more details visit:\n"
|
||||
message += build['url'] + "\n"
|
||||
|
||||
|
@ -818,11 +833,16 @@ class GerritNixConfigurator(ConfiguratorBase):
|
|||
reporters.GerritStatusPush(self.gerrit_server, self.gerrit_user,
|
||||
port=self.gerrit_port,
|
||||
identity_file=self.gerrit_sshkey_path,
|
||||
summaryCB=None,
|
||||
startCB=None,
|
||||
wantSteps=True,
|
||||
reviewCB=gerritReviewCB,
|
||||
reviewArg=self.url)
|
||||
generators=[
|
||||
# gerritReviewCB / self.url
|
||||
BuildStatusGenerator(
|
||||
message_formatter=MessageFormatterFunction(
|
||||
lambda data: gerritReviewFmt(self.url, data),
|
||||
want_properties=True,
|
||||
want_steps=True
|
||||
),
|
||||
),
|
||||
])
|
||||
# startCB, summaryCB are too noisy, we won't use them.
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in a new issue