Setting up private gitlab server for build automation with event notifications to slack

The purpose of this tutorial is to automate android build generation process using CI tools
like Gitlab CI and send event notifications to slack using webhooks.
We are going to use docker for creating local instance of gitlab server and push a simple
android mobile application to gitlab server running on localhost. All the push events
are monitored by sending push event notifications to slack channel.


  1. Deploy gitlab community edition on localhost using docker-compose
  2. Install slack on phone/desktop and connect it to to gitlab instance using webhooks


  1. Install docker and docker-compose on your workstation by following the instructions in the following tutorial:
    a)Docker :-
  2. Install slack desktop/mobile client:


  1. Setup docker compose script for getting docker compose instance up and running:
version: '2'
    restart: always
    image: sameersbn/redis:latest
    - --loglevel warning
    - /srv/docker/gitlab/redis:/var/lib/redis:Z
    restart: always
    image: sameersbn/postgresql:9.6-2
    - /srv/docker/gitlab/postgresql:/var/lib/postgresql:Z
    - DB_USER=admin
    - DB_PASS=password
    - DB_NAME=gitlabhq_production
    - DB_EXTENSION=pg_trgm
    restart: always
    image: sameersbn/gitlab:9.4.5
    - redis
    - postgresql
    - "10080:80"
    - "10022:22"
    - /srv/docker/gitlab/gitlab:/home/git/data:Z
    - DEBUG=false
    - DB_ADAPTER=postgresql
    - DB_HOST=postgresql
    - DB_PORT=5432
    - DB_USER=admin
    - DB_PASS=password
    - DB_NAME=gitlabhq_production
    - REDIS_HOST=redis
    - REDIS_PORT=6379
    - TZ=Asia/Kolkata
    - GITLAB_HTTPS=false
    - SSL_SELF_SIGNED=false
    - GITLAB_HOST=localhost
    - GITLAB_PORT=10080
    - GITLAB_SSH_PORT=10022
    - GITLAB_URL=http://localhost:10080
    - GITLAB_APP_ID='123345234'
    - GITLAB_APP_SECRET='somesecret'
    - GITLAB_CI_SECRETS_SESSION_KEY_BASE="new session key to be added below command"
    - GITLAB_CI_SECRETS_DB_KEY_BASE="new session key to be added below command"
    - GITLAB_SECRETS_DB_KEY_BASE="new session key to be added below command"
    - GITLAB_SECRETS_SECRET_KEY_BASE="new session key to be added below command"
    - GITLAB_SECRETS_OTP_KEY_BASE="new session key to be added below command"

I have used the github repo uploaded here: Dockercompose.yml

You can generate your own session and secret keys using following command in terminal and then add them to above yml file:

pwgen -Bsv1 64

2. Next get Gitlab docker instance up and running using the following command:

docker-compose up

3. Now you sign into gitlab docker instance using gitlab credentials on the following address:


4. Now we can push some sample project to gitlab instance. I have pushed a simple android application which I had created earlier.

5. Next we need to connect slack client to gitlab instance to listen to repo activities and send appropriate alerts to developers on slack channel.
Headover to slack web version and add web hooks by following the steps in official link below:

6.Once you have completed the setup you should see notifications to your slack channel as follows:

slack notifications

7.Next we can setup Gitlab CI runner to automate build generation process:
You will have to install gitlab CI on your workstation by following the official documentation:
Official docs
Then we need to register the runner on gitlab instance as follows:

8.Next we need to configure runners required as per the project. For example for android applications we can use the following yml file which needs to be added to the root folder of target repo(Android application folder):

9.Once the runner is set up the build process or other scheduled jobs can be configured accordingly within gitlab repo settings.

This concludes today’s tutorial for setting up personal gitlab server instance. You can follow technoetics facebook page to receive updates on upcoming tutorials: Codeclassifiers

Keep reading and learning new things everyday 😀

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.