how to read configuration settings from custom hooks?

133 Views Asked by At

We are moving from HG to Rhodecode and we are using custom buildbot hook for building on push event. As mentioned here it is straight forward to add custom mercurial hook in Rhodecode. The issue is we are reading the configuration, e.g. credentials, from rc extension file through ui.config in hook

def hook(ui, repo, hooktype, node=None, source=None, **kwargs):
     username = ui.config('hgbuildbot', 'user', '')
     password = ui.config('hgbuildbot', 'passwd', '')

And the rc extension file is located at : /etc/mercurial-server/remote-hgrc.d/buildbot.rc

[hgbuildbot]
user = username
passwd = secret-password

With these setting in place, mercurial calls this hook and through ui.config we get the credentials, how can we do the same in Rhodecode: how to read from configruations from an rc extension file?

1

There are 1 best solutions below

0
On

Instead of separating code and configuration we ended up writing ansible playbook task that creates the rhodecode rcextension hook with configuration credentials - interpolation - because the separation of code and configuration was not an absolute necessity.

If it is a necessity then one possible option is to create json file which contains these credentials and read this file from the hook.