DEV Community

Cover image for How to CI your project like a champ in 2 minutes
Geoffroy Empain
Geoffroy Empain

Posted on

How to CI your project like a champ in 2 minutes

Today I'll be showing you how to setup CI for your project in less than 2 minutes with Metroline, an open source, self hosted CI. I'll be using Gitea for this tutorial but you could use Gitlab or Github.

Install Metroline (1 minute)

Create a Gitea OAuth app and copy your Client ID and Client Secret

create-gitea-app.mp4

Copy this docker-compose.yml and:
- set METROLINE_GITEA_CLIENT_ID to your Gitea client ID
- set METROLINE_GITEA_CLIENT_SECRET to your Gitea client secret
- set METROLINE_GITEA_URL to the URL of your Gitea server
- change 192.168.43.36 with your IP
- set METROLINE_JWT_SECRET with a random secret obtained from openssl rand 32 -hex
- set METROLINE_RUNNER_SECRET with a random secret obtained from openssl rand 32 -hex

Now, run docker-compose up -d and browse to http://<your-ip>:3000. Click Sign in. You'll see the list of your repos. Click Setup on your favorite project, and you're all set !

setup-repo.mp4

Add CI config file and run first pipeline (30 seconds)

At the root of your project, add a .metroline.yml file with this content:

version: '1'
image: node:12-alpine
jobs:
  install:
    script:
      - npm ci
  test:
    script:
      - npm test
    dependencies:
      - install
Enter fullscreen mode Exit fullscreen mode

Commit, push, and you Metroline starts building your commit immediately.

pipeline.mp4

Pipeline statuses are reported to Gitea as they change. You'll be able to see it next to the commit, and clicking the commit status will open the pipeline in Metroline.

commit-status

Conclusion

I've demonstrated the very basics here, but you can configure parallel jobs, secrets, conditionally execute jobs based on the branch or status of upstream jobs, you can also define pipeline environment, and more.

Also remember that this will work with Github and Gitlab, so I recommend you checkout the installation instructions for your favorite Git server.

Hope you find this useful !

Follow us on Twitter @metrolineio to stay tuned, and share Metroline around you so we can grow our community !

Top comments (0)