[IMP] runbot: log manual batch and redirect

1. Log who started a manull build
2. redirect if the batch given in a build url is not containing this
build (manual url)
This commit is contained in:
Xavier-Do 2022-07-06 13:17:57 +02:00 committed by Christophe Monniez
parent af8a5b8e8e
commit a52c14957e
2 changed files with 5 additions and 0 deletions

View File

@ -280,6 +280,10 @@ class Runbot(Controller):
if from_batch:
from_batch = request.env['runbot.batch'].browse(int(from_batch))
if build_id not in from_batch.with_context(active_test=False).slot_ids.build_id.ids:
# the url may have been forged replacing the build id, redirect to hide the batch
return werkzeug.utils.redirect('/runbot/build/%s' % build_id)
from_batch = from_batch.with_context(batch=from_batch)
Build = request.env['runbot.build'].with_context(batch=from_batch)

View File

@ -455,5 +455,6 @@ class BatchSlot(models.Model):
self.ensure_one()
if self.build_id:
return self.build_id
self.batch_id._log(f'Trigger {self.trigger_id.name} was started by {self.env.user.name}')
self.link_type, self.build_id = self.batch_id._create_build(self.params_id)
return self.build_id