mirror of
https://github.com/odoo/runbot.git
synced 2025-03-15 23:45:44 +07:00
[IMP] runbot: exact rebuild
allow to rebuild using exact config, dependencies, ...
This commit is contained in:
parent
a3ff9d102d
commit
17c57d499e
@ -136,10 +136,13 @@ class Runbot(Controller):
|
||||
build._ask_kill()
|
||||
return werkzeug.utils.redirect('/runbot/repo/%s' % build.repo_id.id + ('?search=%s' % search if search else ''))
|
||||
|
||||
@route(['/runbot/build/<int:build_id>/force'], type='http', auth="public", methods=['POST'], csrf=False)
|
||||
def build_force(self, build_id, search=None, **post):
|
||||
@route([
|
||||
'/runbot/build/<int:build_id>/force',
|
||||
'/runbot/build/<int:build_id>/force/<int:exact>',
|
||||
], type='http', auth="public", methods=['POST'], csrf=False)
|
||||
def build_force(self, build_id, exact=0, search=None, **post):
|
||||
build = request.env['runbot.build'].sudo().browse(build_id)
|
||||
build._force()
|
||||
build._force(exact=bool(exact))
|
||||
return werkzeug.utils.redirect('/runbot/repo/%s' % build.repo_id.id + ('?search=%s' % search if search else ''))
|
||||
|
||||
@route(['/runbot/build/<int:build_id>'], type='http', auth="public", website=True)
|
||||
|
@ -367,7 +367,7 @@ class runbot_build(models.Model):
|
||||
params['dep'][result[0]] = result[1]
|
||||
return params
|
||||
|
||||
def _force(self, message=None):
|
||||
def _force(self, message=None, exact=False):
|
||||
"""Force a rebuild and return a recordset of forced builds"""
|
||||
forced_builds = self.env['runbot.build']
|
||||
for build in self:
|
||||
@ -382,10 +382,11 @@ class runbot_build(models.Model):
|
||||
build.write({'local_state': 'pending', 'sequence': sequence, 'local_result': ''})
|
||||
# or duplicate it
|
||||
elif build.local_state in ['running', 'done', 'duplicate', 'deathrow']:
|
||||
new_build = build.with_context(force_rebuild=True).create({
|
||||
values = {
|
||||
'sequence': sequence,
|
||||
'branch_id': build.branch_id.id,
|
||||
'name': build.name,
|
||||
'date': build.date,
|
||||
'author': build.author,
|
||||
'author_email': build.author_email,
|
||||
'committer': build.committer,
|
||||
@ -393,10 +394,24 @@ class runbot_build(models.Model):
|
||||
'subject': build.subject,
|
||||
'modules': build.modules,
|
||||
'build_type': 'rebuild',
|
||||
# 'config_id': build.config_id.id,
|
||||
# we use the branch config for now since we are recomputing dependencies,
|
||||
# we may introduce an 'exact rebuild' later
|
||||
})
|
||||
}
|
||||
if exact:
|
||||
values.update({
|
||||
'config_id': build.config_id.id,
|
||||
'extra_params': build.extra_params,
|
||||
'dependency_ids': build.dependency_ids,
|
||||
'server_match': build.server_match,
|
||||
'orphan_result': build.orphan_result,
|
||||
})
|
||||
#if replace: ?
|
||||
if build.parent_id:
|
||||
values.update({
|
||||
'parent_id': build.parent_id.id, # attach it to parent
|
||||
'hidden': build.hidden,
|
||||
})
|
||||
build.orphan_result = True # set result of build as orphan
|
||||
|
||||
new_build = build.with_context(force_rebuild=True).create(values)
|
||||
build = new_build
|
||||
else:
|
||||
rebuild = False
|
||||
|
@ -4,7 +4,17 @@
|
||||
$(function() {
|
||||
$('a.runbot-rebuild').click(function() {
|
||||
var $f = $('<form method="POST">'),
|
||||
url = _.str.sprintf('/runbot/build/%s/force', $(this).data('runbot-build')) + window.location.search;
|
||||
url = _.str.sprintf('/runbot/build/%s/force', $(this).data('runbot-build')) + window.location.search;
|
||||
$f.attr('action', url);
|
||||
$f.appendTo($('body'));
|
||||
$f.submit();
|
||||
return false;
|
||||
});
|
||||
});
|
||||
$(function() {
|
||||
$('a.runbot-rebuild-exact').click(function() {
|
||||
var $f = $('<form method="POST">'),
|
||||
url = _.str.sprintf('/runbot/build/%s/force/1', $(this).data('runbot-build')) + window.location.search;
|
||||
$f.attr('action', url);
|
||||
$f.appendTo($('body'));
|
||||
$f.submit();
|
||||
|
@ -67,7 +67,14 @@
|
||||
<li><a t-attf-href="http://{{bu['domain']}}/">Connect <i class="fa fa-sign-in"></i></a></li>
|
||||
</t>
|
||||
<li t-if="bu.global_state in ['done','running','deathrow'] and bu_index==0" groups="base.group_user">
|
||||
<a href="#" class="runbot-rebuild" t-att-data-runbot-build="bu['id']">Rebuild <i class="fa fa-refresh"/></a>
|
||||
<a href="#" class="runbot-rebuild" t-att-data-runbot-build="bu['id']"
|
||||
title="Create a new build keeping build commit head, but will recompute all other info (config, dependencies, extra_params)">
|
||||
Default Rebuild <i class="fa fa-refresh"/>
|
||||
</a>
|
||||
<a href="#" class="runbot-rebuild-exact" t-att-data-runbot-build="bu['id']"
|
||||
title="Create a new build keeping all build info (config, dependencies, extra_params)">
|
||||
Exact Rebuild <i class="fa fa-refresh"/>
|
||||
</a>
|
||||
</li>
|
||||
<li t-if="bu.global_state in ['pending','testing', 'waiting', 'running']" groups="base.group_user">
|
||||
<a href="#" class="runbot-kill" t-att-data-runbot-build="bu['id']">Kill <i class="fa fa-crosshairs"/></a>
|
||||
|
Loading…
Reference in New Issue
Block a user