Gerrit offers a system to customize the web theme. When static/gerrit-theme.js exists, it is loaded as a plugin and we have been using it to load a few customization. The file is hosted in Puppet at modules/gerrit/files/homedir/review_site/static/gerrit-theme.js and contains several different features all mixed up in a single plugin registration.
That causes several issues:
- when upgrading Gerrit to a new minor version we might have to do adjust the embedded plugin. Release-Engineering-Team can do the upgrade via scap but changes to gerrit-theme.js requires a Puppet change and thus synchronization with SRE.
- the gerrit-theme.js file embeds different features:
- A CI test results table inspired from https://github.com/dburm/pg-test-result-plugin (T256575)
- Support for dark/light styles (T227509)
- custom links to the WMF Code of Conduct and Privacy Policy (T196835)
- a link to https://codesearch.wmcloud.org/search/ (T264163)
I have found out Gerrit supports loading plugins from a single Javascript file in the plugins directory instead of having to create a JAR plugin. The name of the javascript file is used as a plugin name (MyCustomLink.js would be named MyCustomLink). It is hinted at: https://gerrit.wikimedia.org/r/Documentation/dev-plugins.html#deployment
Thus we can split gerrit-theme.js in multiple files that would be stored in operations/software/gerrit deployment branch under the plugins directory. The new .js files would sit along the existing .jar files.
When deploying a JavaScript plugin, we can rely on plugins.checkFrequency to have Gerrit reload it entirely every minute.