CI tools testing lab: Adding Zuul Merger

zip-159043_1280zuul-merger is a component of Zuul that merges code patches together to emulate the state code will be in once those patches are merged.  This post describes how I’ve ran it in a Docker container as part of a lab setup.

This post is the fourth in a series of posts describing how I’ve used Docker to build a lab setup on my laptop to try out Zuul and check out its various features. Previously I’ve described how to install Jenkins, Gerrit and add zuul-server.

To have a useful zuul-merger service, we need to run two services – zuul-merger itself, and an HTTP server to make the code built by zuul-merger available to Jenkins. But first, we need to write a configuration file.

Zuul merger configuration

To keep things easy to play with, I’m going to make the zuul-server and zuul-merger share the same configuration directory, and more importantly, the same “zuul.conf” file. To edit the “zuul.conf” file I’ve created with the zuul-server container, I run this command:

sudo docker exec -it zuul-server vi /etc/zuul/zuul.conf

Note: I could also edit the file directly from “/tmp/zuul/conf“, where it is stored outside the container, but I found editing through the container to be simpler with less need to worry about file permissions and  SElinux.

Here is the contents of my “zuul.conf” file that combines both zuul-server and zuul-merger configuration:





[connection gerrit]

Primarily I’ve added the “merger” section which specifies that:

  1. The code should be placed in “/git” which will be a shared, persistent volume.
  2. From which HTTP URL the code will be made available to Jenkins.

The “gearman” and “connection” sections are also important for zuul-merger as it connects to zuul-server via Gearman and to Gerrit directly.

The zuul-merger container

The zuul-merger container is very similar to the zuul-server container I described in a previous post. The files to built it can be seen on GitHub. The command to build it would be:

sudo docker build -t zuul_merger:latest zuul_merger/

The following script would start the container:

#!/bin/bash -x
DIRS=(/tmp/zuul/conf /tmp/zuul-merger/state /tmp/zuul/git)
for dir in "${DIRS[@]}"; do
    [[ -d "$dir" ]] && continue
    sudo install -o 1001 -g 0 -d "$dir"
sudo docker run -d \
    -v /tmp/zuul/conf:/etc/zuul:z \
    -v /tmp/zuul-merger/state:/var/lib/zuul:Z \
    -v /tmp/zuul/git:/git:z \
    --name zuul-merger \
sudo docker inspect \
    -f $'Container running at: {{.NetworkSettings.IPAddress}} With ports: {{range $k, $v := .NetworkSettings.Ports}}{{$k}} {{end}}' \

The thing to note is that we’re mounting the same configuration directory that we’ve used for the zuul-server container, as well as a directory to “/git” in a way that would make SElinux allow it to be shared with other containers.

We can take a look at the “zuul-merger” logs with the following command:

sudo docker logs -tf zuul-merger

We can also use “ncat” to connect to Gearman running in the “zuul-server” container to ensure “zuul-merger” registered itself:

echo workers | ncat 4730

We should get a line like the following indicating zuul-merger connected as a worker to Gearman.

20 Zuul Merger : merger:merge merger:update

The HTTP container

Since its very easy to find examples on how to share Git repositories via Apache, we’re just going to build a container around it. Here is the configuration snippet we’ll add to our container to make Apache serve Git:


AliasMatch ^/p/(.*/objects/[0-9a-f]{2}/[0-9a-f]{38})$ /git/$1
AliasMatch ^/p/(.*/objects/pack/pack-[0-9a-f]{40}.(pack|idx))$ /git/$1
ScriptAlias /p/ /usr/libexec/git-core/git-http-backend/

<LocationMatch "^/p">
    Require all granted

I’ve built the container on top of OpenShift’s basic CentOS container. The “Dockerfile” to build it could be found on Git Hub. The build command would be:

sudo docker build -t zuul-git-server zuul_git_server/

We need to run the container while mounting the shared “/git” volume, here is a script to do this:

#!/bin/bash -x
for dir in "${DIRS[@]}"; do
    [[ -d "$dir" ]] &amp;amp;&amp;amp; continue
    sudo install -o 1001 -g 0 -d "$dir"
sudo docker run -d \
    -v /tmp/zuul/git:/git:z \
    --name zuul-git-server \
sudo docker inspect \
    -f $'Container running at: {{.NetworkSettings.IPAddress}} With ports: {{range $k, $v := .NetworkSettings.Ports}}{{$k}} {{end}}' \

So far we’ve brought up the core components of Zuul. We still have some work to make it connect to Jenkins, expose its graphical user interface and finally create Jenkins jobs and Zuul pipelines to invoke them. I will describe these steps in the next instalments.


2 thoughts on “CI tools testing lab: Adding Zuul Merger

  1. Pingback: CI tools testing lab: Integrating Jenkins and adding Zuul UI | Ifblog (ponderings 2.0)

  2. Pingback: CO tools testing lab: Making it do useful work | Ifblog (ponderings 2.0)

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s