Gitlab CI/CD

Continuous Integration and Deployment (CI/CD) is the process of automating the build and deployment of locally developed source code to remote servers. In Gitlab, this can be done by installing gitlab-runner software on a “production” server, with the developers including a .gitlab-ci.yml file as part of their Git repository.

When a developer pushes their completed source code back to their Gitlab repository, the remote “production” server running the gitlab-runner application clones the newly updated repository and executes the build/test commands on the source code that have been included in the .gitlab-ci.yml file. The developer needs to include all of the commands necessary to adequately build, test and deploy their source code in their .gitlab-ci.yml file.

Gitlab CI Pipelines

Automating build/test/deployment with a Gitlab CI Pipeline requires 2 components:

  1. A .gitlab-ci.yml file stored in the base directory of the git repository. This file contains the automation instructions for the build, test, deployment procedures that will be triggered on a successful push/merge. The Department has created a few sample .gitlab-ci.yml files that can perform some simple build/deployment activities.

  2. A gitlab-runner executable must be running somewhere in your build environment. The runner can either be a shared runner installed on a private application server that you have been given access to by an instructor, or a private runner that you have configured and have running locally on your laptop.

The gitlab-runner executable will execute the commands found in your repositories’ .gitlab-ci.yml file. The computer executing the gitlab-runner program needs to have installed all of the software required to complete any test procedures you have defined in your .gitlab-ci.yml file as well as the software necessary to compile/build your source code and deliver/deploy your built source code to its production destination.