[FIX] runbot: small fixed to ease deployment

This commit is contained in:
Xavier-Do 2022-01-24 15:12:29 +01:00 committed by Christophe Monniez
parent ec2f12ef5f
commit 8cdb8c9e5b
5 changed files with 15 additions and 3 deletions

View File

@ -222,6 +222,9 @@ class Branch(models.Model):
self.bundle_id.defined_base_id = base.id
self.bundle_id._force()
if self.draft:
self.reviewers = '' # reset reviewers on draft
if (not self.draft and was_draft) or (self.alive and not was_alive) or (self.target_branch_name != init_target_branch_name and self.alive):
self.bundle_id._force()

View File

@ -1,9 +1,11 @@
import logging
from odoo import models, fields, api
from odoo.tools import config
from ..common import fqdn, local_pgadmin_cursor, os
from ..container import docker_build
_logger = logging.getLogger(__name__)
forced_host_name = None
class Host(models.Model):
_name = 'runbot.host'
@ -94,8 +96,8 @@ class Host(models.Model):
return os.path.abspath(os.path.join(os.path.dirname(__file__), '../static'))
@api.model
def _get_current(self, suffix=''):
name = '%s%s' % (fqdn(), suffix)
def _get_current(self):
name = config.get('forced_host_name') or fqdn()
return self.search([('name', '=', name)]) or self.create({'name': name})
def get_running_max(self):

View File

@ -366,7 +366,7 @@ class Repo(models.Model):
if not git_refs:
return []
refs = [tuple(field for field in line.split('\x00')) for line in git_refs.split('\n')]
refs = [r for r in refs if dateutil.parser.parse(r[2][:19]) + datetime.timedelta(days=max_age) > datetime.datetime.now() or self.env['runbot.branch'].match_is_base(r[0])]
refs = [r for r in refs if dateutil.parser.parse(r[2][:19]) + datetime.timedelta(days=max_age) > datetime.datetime.now() or self.env['runbot.branch'].match_is_base(r[0].split('\n')[-1])]
if ignore:
refs = [r for r in refs if r[0].split('/')[-1] not in ignore]
return refs

View File

@ -44,6 +44,8 @@
<field name="config_id"/>
<field name="ci_context"/>
<field name="repo_ids" widget="many2many_tags"/>
<field name="dependency_ids" widget="many2many_tags"/>
<field name="manual"/>
</tree>
</field>
</record>

View File

@ -46,6 +46,7 @@ class RunbotClient():
while True:
try:
self.host.last_start_loop = fields.Datetime.now()
self.env.cr.commit()
self.count = self.count % self.max_count
sleep_time = self.loop_turn()
self.count += 1
@ -90,6 +91,8 @@ def run(client_class):
parser.add_argument('--db_password')
parser.add_argument('-d', '--database', default='runbot', help='name of runbot db')
parser.add_argument('--logfile', default=False)
parser.add_argument('--forced-host-name', default=False)
args = parser.parse_args()
if args.logfile:
dirname = os.path.dirname(args.logfile)
@ -113,6 +116,8 @@ def run(client_class):
config_addons_path = odoo.tools.config['addons_path']
odoo.tools.config['addons_path'] = ','.join([config_addons_path, addon_path])
odoo.tools.config['forced_host_name'] = args.forced_host_name
# create environment
registry = odoo.registry(args.database)
with odoo.api.Environment.manage():