Continuous Delivery System Based on Gitlab

Setup Gitlab

Run the following command to install gitlab on your machine.

sudo docker run -d --hostname \
-p 80:80 -p 443:443 -p 22:22 \
--restart always gitlab/gitlab-ce

Please follow official installation docs to install docker if it’s not been installed. Do NOT forget change and /srv/gitlab/ to your own.(I have a virtual machine with that ip.) If your docker is behind a proxy, please see the search results from Google.

After several mins, access (the host you set above), you will the following picture. pic-create-password

Set your admin password, and login again.

Gitlab Home Page

Create new project hello-world as the following:

Create new project

Once you create the project, follow the instruction to upload demo code to the repo. When you finish you will see a similar picture.

Gitlab project setup ci

Click the Set up CI button, add the following code and commit.

  - echo 'hello world'

A pending icon will appear on the result page.

Gitlab commit pending to run

Click the icon, you will see a stuk tag on your commit. That means you have to add gitlab-runner to this project.

Setup Gitlab Runner

  1. Open CI/CD Pipeline tab in project settings Gitlab project runner setup

  2. Install setup runner on your local machine

     brew install gitlab-ci-multi-runner
  3. Register your local machine as a runner to the gitlab

    Gitlab runner register

  4. Runner list

    Project runner list

  5. Go back to the Pipelines of your project and click the retry button

  6. You runner has been set up successfully when you see the picture

  7. Change the .gitlab-ci.yml to the following:

       - ./gradlew aR
         - app/build/outputs/apk/app-release*.apk
  8. Now you will get the release apk file from the download button.