A month ago I started working in a new project, Last time I wrote about how I built my development environment from the Virtual Appliance received, today I’m gonna tell you about how I set up Gitlab CI for continuous integration, our repositories are stored in a Gitlab CE instance.

I’ve built a virtual machine for testing, the same way I built one for development.

Gitlab CI gives you a lot of flexibility on how to run your tests, they provide you with a runner, a service executing your tests and sending the result to your Gitlab instance.

You can run more of one runner concurrently and there are different options on how to set the test environment (docker, shell, ssh…).

Since I’m using a virtual machine on Virtualbox to run my tests, I use the ssh strategy.

To configure the runner first we need to clone the repository.

$ git clone https://gitlab.com/gitlab-org/gitlab-ci-multi-runner.git

Once we have It cloned and installed following Its instructions, we can register a runner. You’ll need a token to configure It, you can find this token in the settings of your project, in the Gitlab website.

$ gitlab-ci-multi-runner register
Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/ci )
Please enter the gitlab-ci token for this runner
Please enter the gitlab-ci description for this runner
INFO[0034] fcf5c619 Registering runner... succeeded
Please enter the executor: shell, docker, docker-ssh, ssh?


INFO[0037] Runner registered successfully.

Feel free to start it, but if it's
running already the config should be automatically reloaded!

Once you register the runner, It will create a file in your $HOME: ~/.gitlab-runner/config.toml. It has the following format.

# config.toml

concurrent = 1

  url = "https://gitlab.com/ci"
  token = "tokenrepo"
  tls-skip-verify = false
  tls-ca-file = ""  
  name = "surf"
  executor = "ssh"
    user = "root"
    host = "localhost"
    port = "2222"
    identity_file = "/Users/javaguirre/.ssh/ci_rsa"

You could just edit this information if you change something on your runner, once you’re happy with the configuration, you just run the runner.

gitlab-ci-multi-runner run


gitlab-ci-multi-runner start

I want to use Docker to run the tests, but It’s not a priority now, once I have It running I’ll share my impressions with you. :-)