There isn't a good way to do this. We didn't export the server version
of HTTP until master (aka 2.8), and even then its embedded into the
host page data object in the / HTML response. Which is never fun to
parse from a program.
But I did find a backdoor into the version for you. Its still not
pretty but may be workable.
Parse the HTML of
https://gerrit-review.googlesource.com/tools/hooks/.
There is a "Powered by Gerrit Code Review" footer buried in an <p>
tag:
$ curl
https://gerrit-review.googlesource.com/tools/hooks/
<html><head><META http-equiv="Content-Type" content="text/html;
charset=UTF-8"><title>Gerrit Code Review -
/tools/hooks</title></head><body><h1>Gerrit Code Review -
/tools/hooks</h1><ul><li><a
href="commit-msg">commit-msg</a></li></ul><hr><p style="text-align:
right; font-style: italic">Powered by Gerrit Code Review
2.7-rc2-647-gba149ce</p></body></html>
This feature first appeared in 2.1.2-rc0 and has been available
unmodified since.
A change to add /config/server/version as a REST API that can be more
reliably polled and parsed would be welcome.