diff --git a/runbot/models/build.py b/runbot/models/build.py index 663fefae..b274e7cf 100644 --- a/runbot/models/build.py +++ b/runbot/models/build.py @@ -718,6 +718,14 @@ class runbot_build(models.Model): p = subprocess.Popen(cmd, stdout=out, stderr=out, preexec_fn=preexec_fn, shell=shell, env=env, close_fds=False) return p.pid + def _github_status_notify_all(self, status): + """Notify each repo with a status""" + self.ensure_one() + commits = {(b.repo_id, b.name) for b in self.search([('name', '=', self.name)])} + for repo, commit_hash in commits: + _logger.debug("github updating %s status %s to %s in repo %s", status['context'], commit_hash, status['state'], repo.name) + repo._github('/repos/:owner/:repo/statuses/%s' % commit_hash, status, ignore_errors=True) + def _github_status(self): """Notify github of failed/successful builds""" runbot_domain = self.env['runbot.repo']._domain() @@ -734,16 +742,13 @@ class runbot_build(models.Model): desc += " (runtime %ss)" % (build.job_time,) else: continue - commits = {(b.repo_id, b.name) for b in self.search([('name', '=', build.name)])} - for repo, commit_hash in commits: - status = { - "state": state, - "target_url": "http://%s/runbot/build/%s" % (runbot_domain, build.id), - "description": desc, - "context": "ci/runbot" - } - _logger.debug("github updating status %s to %s", build.name, state) - repo._github('/repos/:owner/:repo/statuses/%s' % commit_hash, status, ignore_errors=True) + status = { + "state": state, + "target_url": "http://%s/runbot/build/%s" % (runbot_domain, build.id), + "description": desc, + "context": "ci/runbot" + } + build._github_status_notify_all(status) # Jobs definitions # They all need "build, lock_pathn log_path" parameters diff --git a/runbot_cla/runbot.py b/runbot_cla/runbot.py index afb3ba67..09d74d14 100644 --- a/runbot_cla/runbot.py +++ b/runbot_cla/runbot.py @@ -38,6 +38,6 @@ class runbot_build(models.Model): "context": "legal/cla" } build._log('check_cla', 'CLA %s' % state) - build.repo_id._github('/repos/:owner/:repo/statuses/%s' % build.name, status, ignore_errors=True) + build._github_status_notify_all(status) # 0 is myself, -1 is everybody else, -2 nothing return -2