6.4. GitLab Tips and Tricks

6.4.1. General Description

The goal of this Wiki page is to collect and share all possible needed information to be view-able by all the working team.

6.4.2. CI / CD steps

CI / CD is a GitLab built-in tool which provides continuous integration, continuous development and continuous deployment of your software within one place.

6.4.2.1. Execution of CI

To see how to run job sequentially, in parallel or build a custom pipeline, please refer to GitLab CI: Run jobs sequentially, in parallel or build a custom pipeline

6.4.2.2. Configuration of CI

The GitLab CI/CD feature is based on a unique configuration file named ".gitlab-ci.yml" which shall be placed at the root of your project's repository. Please see this GitLab documentation page about .gitlab-ci.yml file for more details about the possibilities of GitLab CI/CD feature.

6.4.2.3. Cache and artifact

6.4.2.3.1. Cache (store locally generated file)

If you want to cache the installation files for your projects dependencies, for building faster, you can use the parameter cache. However, this shall be used with cautions since if you update the part of your repository which is cached by your .gitlab-ci.yml, then it won't be updated by your Runner and you may have quite some hard time finding out the root cause of your issue (true story...). You can find more details about this functionality in GitLab Official documentation

In the following example, the option untracked is enabled. It allows to keep all files even if they are not tracked in the git:

yml build: stage: build script: - myscript cache: untracked: true paths: - BIN

The cached files will be on the machine which runs GitLab's Runner:

cache_gitlab_runner

6.4.2.3.2. Artifact (Store files generated during your pipeline execution)

Although GitLab provides a complete history of the pipelines and jobs which have been executed, you may need to have more details of your job execution for further debugging, like generated assembly files for examples. In order to be able to retrieve and download such files from GitLab CI/CD interface, you need to use the GitLab job artifact functionality.

Example of artifact for 1133_EGOS_GROUP/EGOS_Project/PRJ/MAKEFILE content backup:

build:
  script:
    - cd ./PRJ/MAKEFILE/
    - pwd
    - make --version
    - make build_from_sources -j
    - cd ../..
  artifacts:
    name: "Makefile"
    paths:
    - PRJ/MAKEFILE
    expire_in: 1 week

Once the job is finished, you will have access to the following buttons on Gitlab Pipeline page, allowing you to download a zip files containing the artifacts by clicking on Download build artifacts :

Capture

On the dedicated job page, you also have the possibility to visualize the artifacts by clicking on Browse, to download them and to Keep them for a GitLab's instance wide duration (30 days) instead of the configured project's duration (7 days):

image

6.4.3. Merge request

6.4.3.1. Code review

To avoid problem of communication on merge request, it could be good to move from the discussion view to the changes view.

Changes_view

It could be easier to understand on which lines the review will be applied and then to open the file and update it. You see all the modified files in this merge request and the comments of the reviewer(s). The tagged line could be more ambiguous in the discussion view than in the changes view:

In the discussion view:

Capture_discussion_view

In the changes view:

Capture_changes_view

6.4.4. Wiki Sidebar edition

In order to edit the sidebar (on the right side) of the wiki, you need to edit the page named "_sidebar" so that you can add link, and maybe other customer fields since it's like a wiki page, but dedicated for the side bar.

Note that this page is not visible nor downloadable via git, you need to type the address in your web browser directly.

6.4.5. E-mail notification settings

GitLab allows you to configure precisely when you should be notified of events occurring on your project(s). In order to configure this, you need to:

  • Go to your user settings

  • Select Notifications on the left panel

  • Select the project you want to configure: by default it is configured to "Global"

  • You can adapt these settings by selecting on of the proposed configuration by clicking on the 🔔 button

  • The "Custom" option allows you to select on which detailed event you will be notified: from "Close issue" to "Failed pipeline", you have a large choice of options available.