mirror of
https://github.com/odoo/runbot.git
synced 2025-03-15 23:45:44 +07:00
[FIX] runbot: choose quickconnect build with same config
When the quickconnect button is used, the last running build is searched in the last 10 builds. If no running build is found, the last one is rebuilt, even if it's a nightly build. With this commit, the quickconnect build is choosen only among the ones with the same config.
This commit is contained in:
parent
0384f2c98b
commit
c24df5fac2
@ -178,27 +178,20 @@ class Runbot(Controller):
|
||||
}
|
||||
return request.render("runbot.build", context)
|
||||
|
||||
@route(['/runbot/b/<branch_name>', '/runbot/<model("runbot.repo"):repo>/<branch_name>'], type='http', auth="public", website=True)
|
||||
def fast_launch(self, branch_name=False, repo=False, **post):
|
||||
@route(['/runbot/quick_connect/<model("runbot.branch"):branch>'], type='http', auth="public", website=True)
|
||||
def fast_launch(self, branch, **post):
|
||||
"""Connect to the running Odoo instance"""
|
||||
Build = request.env['runbot.build']
|
||||
|
||||
domain = [('branch_id.branch_name', '=', branch_name)]
|
||||
|
||||
if repo:
|
||||
domain.extend([('branch_id.repo_id', '=', repo.id)])
|
||||
order = "sequence desc"
|
||||
else:
|
||||
order = 'repo_id ASC, sequence DESC'
|
||||
domain = [('branch_id', '=', branch.id), ('config_id', '=', branch.config_id.id)]
|
||||
|
||||
# Take the 10 lasts builds to find at least 1 running... Else no luck
|
||||
builds = Build.search(domain, order=order, limit=10)
|
||||
builds = Build.search(domain, order='sequence desc', limit=10)
|
||||
|
||||
if builds:
|
||||
last_build = False
|
||||
for build in builds:
|
||||
if build.local_state == 'running' or (build.local_state == 'duplicate' and build.duplicate_id.local_state == 'running'):
|
||||
last_build = build if build.local_state == 'running' else build.duplicate_id
|
||||
if build.real_build.local_state == 'running':
|
||||
last_build = build.real_build
|
||||
break
|
||||
|
||||
if not last_build:
|
||||
@ -208,7 +201,7 @@ class Runbot(Controller):
|
||||
if last_build.local_state != 'running':
|
||||
url = "/runbot/build/%s?ask_rebuild=1" % last_build.id
|
||||
else:
|
||||
url = build.branch_id._get_branch_quickconnect_url(last_build.domain, last_build.dest)[build.branch_id.id]
|
||||
url = "http://%s/web/login?db=%s-all&login=admin&redirect=/web?debug=1" % (last_build.domain, last_build.dest)
|
||||
else:
|
||||
return request.not_found()
|
||||
return werkzeug.utils.redirect(url)
|
||||
|
@ -93,12 +93,6 @@ class runbot_branch(models.Model):
|
||||
|
||||
return super(runbot_branch, self).create(vals)
|
||||
|
||||
def _get_branch_quickconnect_url(self, fqdn, dest):
|
||||
self.ensure_one()
|
||||
r = {}
|
||||
r[self.id] = "http://%s/web/login?db=%s-all&login=admin&redirect=/web?debug=1" % (fqdn, dest)
|
||||
return r
|
||||
|
||||
def _get_last_coverage_build(self):
|
||||
""" Return the last build with a coverage value > 0"""
|
||||
self.ensure_one()
|
||||
|
@ -119,7 +119,7 @@
|
||||
<small><t t-esc="br['builds'] and br['builds'][0].get_formated_build_time()"/></small><br/>
|
||||
<div class="btn-group btn-group-xs">
|
||||
<a t-attf-href="{{br['branch'].branch_url}}" class="btn btn-default btn-xs">Branch or pull <i class="fa fa-github"/></a>
|
||||
<a t-attf-href="/runbot/#{repo.id}/#{br['branch'].branch_name}" class="btn btn-default btn-xs" aria-label="Quick Connect"><i class="fa fa-fast-forward" title="Quick Connect"/></a>
|
||||
<a t-attf-href="/runbot/quick_connect/#{br['branch'].id}" class="btn btn-default btn-xs" aria-label="Quick Connect"><i class="fa fa-fast-forward" title="Quick Connect"/></a>
|
||||
</div>
|
||||
<t t-if="br['branch'].sticky">
|
||||
<br/>
|
||||
|
Loading…
Reference in New Issue
Block a user