6.4. GitLab Tips and Tricks¶
The goal of this Wiki page is to collect and share all possible needed information to be view-able by all the working team.
CI / CD is a GitLab built-in tool which provides continuous integration, continuous development and continuous deployment of your software within one place.
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
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.
18.104.22.168.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:
The cached files will be on the machine which runs GitLab's Runner:
22.214.171.124.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 :
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):
To avoid problem of communication on merge request, it could be good to move from the discussion view to the 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:
In the changes view:
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.