Skip to content

Using GitLab CI for Building LaTeX

Aras Ergus edited this page Oct 3, 2016 · 3 revisions

You can use GitLab's continuous integration service to build your LaTeX projects. Detailed information is available here.

Our CI server may be deprecated in the future in favor of this service (because it seems like a decent one and running an own CI server needs a remarkable portion of the resources of our server).

Quick & Simple Configuration

Steps

  1. Host your repository on gitlab.com (or another GitLab instance which works with GitLab CI).
  2. Push a file called .gitlab-ci.yml to your repository with the following content:
compile_pdf:
  image: aergus/latex
  script:
    - latexmk -pdf my_file.tex
  artifacts:
    paths:
      - my_file.pdf

where you should replace my_file with the name of your main TeX file (and add a directory path if needed).

Builds will appear in https://gitlab.com/<namespace>/<repo name>/pipelines (or a similar URL if you are using another host). The PDF files will be in the "build artifacts" of each build.

Explanation

After each push, GitLab will build your project using the configuration in .gitlab-ci.yml.

The configuration file above tells GitLab to create a clone of the Docker image aergus/latex and hence run latexmk in a "sandboxed" environment. In this configuration, your project will be built on a Debian system which has texlive-full (minus the documentation packages) installed. This means that all TeX packages included in Debian will be at your service and you will have to try hard to find a package which is unavailable.

Alternatively, you can also use the image tianon/latex which is based on Debian stable (and hence has in general older versions of TeX packages) and has a slightly larger image size (because it contains some documentation packages which are not needed for building LaTeX documents). It should be OK to use a decent-looking Docker configuration created by a random person as it cannot do anything to your files/repo/account/whatever. That's the point of a sandbox.