chore(reporters): make it 3.11+ (and 4.0) compatible!
Signed-off-by: Raito Bezarius <raito@lix.systems>
This commit is contained in:
parent
b20d0a17ba
commit
449837ed81
|
@ -19,6 +19,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
|
||||
|
@ -728,7 +730,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()
|
||||
|
||||
|
@ -753,7 +768,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"
|
||||
|
||||
|
@ -850,11 +865,17 @@ 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),
|
||||
"plain",
|
||||
want_properties=True,
|
||||
want_steps=True
|
||||
),
|
||||
),
|
||||
])
|
||||
# startCB, summaryCB are too noisy, we won't use them.
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in a new issue