Continuous integration/Documentation generation

We automatically generate documentation on https://doc.wikimedia.org/ which is hosted on a production machine. Since the doc is often generated on labs instance, we had to set up a two step process to be able to move the doc from labs to production. This page document the workflow being used and part of the technical implementation.

Zuul
Our reacts on two kind of Gerrit events which are matched by two different pipelines:

ref-updated could cover the changes being merged, but the event is not associated with a Gerrit change number which prevents us from reporting back to the Gerrit interface. We thus use postmerge to report back to user and publish which handles references updates matching ^refs/tags/.

A single job is used to generate the documentation for any branch or tag, we thus need to namespace the documentation based on the branch name or the tag name. The information is carried differently between events and the reference is slightly different between branch updates and tags. The conversion logic is carried by a which is associated to all the publish jobs. It injects to the Gearman function (and thus the Jenkins job environment) a variable DOC_SUBPATH which represents the version. Example:


 * change merged on REL1_24 branch: DOC_SUBPATH = REL1_24
 * refs/tags/1.24.0 updated: DOC_SUBPATH = 1.24.0

Reference:

We can thus reuse that parameter to easily namespace the jobs per version.

Jenkins job builder definitions
Most of the logic is defined straight in Jenkins Job Builder doc.yaml configuration file.

In a job definition, a builder define the command to generate the documentation which ends up being written in a build_path</tt>. We then have a macro push-doc</tt> which takes care of publishing the documentation to the production server. It takes two parameters:
 * 1) docsrc</tt> which is the place where the doc has been generated (build_path from above)
 * 2) docdest</tt> the final destination path under https://doc.wikimedia.org/

Example job definition:

Will invoke make doc</tt> and publish the content under doc/build/html</tt> at https://doc.wikimedia.org/myproject/.

Architecture
The documentations are ultimately published on doc.wikimedia.org which is a production machine (gallium</tt> as of Sep. 2014). They are generated on labs instance part of the integration</tt> labs project which are not allowed to communicate with production machines.

To solve this, we created an intermediary instance integration-publisher.eqiad.wmflabs</tt>, the push-doc</tt> macro running on the labs instance will rsync the generated content to the instance under the doc</tt> rsync container in a uniquely named sub directory (reusing ZUUL_UUID). The macro then triggers the publish-doc</tt> job with the unique identifier, it will rsync from the intermediary instance to the production machine, thus publishing the doc.

The integration-publisher.eqiad.wmflabs</tt> rsync daemon is reachable by other integration labs instances since they are in the same project. The production slave gallium is allowed connection since it has a public IP and can reach labs, the other production slave lanthanum has a private IP and thus can not reach labs per policy. Hence all jobs should be tied to the contintLabsSlave</tt> label.