Installing Gitlab CI

Submitted by Tha-Fox on 2019-08-07

I've had self hosted Gitlab instance running for a long time along the service. After an upgrade I noticed Gitlab had CI enabled on repositories by default. This got me pondering on enabling the CI features on my own instance. I'm using Ubuntu 18.04, but on the official instructions there are other distributions like CentOS, Fedora and Debian, mentioned. So here is a brief guide to my future self.

  1. Add the repository for Gitlab runner
    curl -L | sudo bash
  2.  Install the runner
    sudo apt-get install gitlab-runner
  3. I know beforehand that I want to use Docker as my executor, so I install it before registering the runner.
    sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
  4. Add Docker's official GPOG  key
    curl -fsSL | sudo apt-key add -
  5. Check the key fingerprint
    sudo apt-key fingerprint 0EBFCD88
  6. Add the stable repository. It is also possible to use test or nightly repository.
    sudo add-apt-repository "deb [arch=amd64] $(lsb_release -cs) stable"
  7. Install Docker Engine - Community and containerd
    sudo apt-get install docker-ce docker-ce-cli
  8. Test Docker by running the hello-world container
    sudo docker run hello-world
  9. Register the runner. If you want to install a shared runner, you have to have admin access to .Gitlab instance. While installing shared instance, you can find the URL and token from the Gitlab UI by going to admin/runners. The rest of the options are told here.
  10. I selected Docker as my executor, so I have to give the default Docker image, in case projects do not define one in .gitlab-ci.yml. I choose Alpine Linux as it is popular distribution with small footprint.

When the runner has been installed and registered, it is visible in Gitlab. Now all you need to do is add .gitlab-ci.yml to the root of your repository and start wondering what to do with it.


Add new comment

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.