DEV Community

Cover image for Best New Features in GitLab 14.2 and 14.3 ⛲
Benjamin Rancourt
Benjamin Rancourt

Posted on • Originally published at benjaminrancourt.ca on

Best New Features in GitLab 14.2 and 14.3 ⛲

Last month, on September 22, GitLab 14.3 was released. It made me realize that I forgot to check the releases notes for the previous version, 14.2. 😅

So, in this post, I'm going to address that by highlighting some of the new features and improvements that you might be interested in. 😬

GitLab 14.2

Use CI/CD variables in include statements in .gitlab-ci.yml

By allowing the use of variables inside the include keyword, it will open new ways to define CI/CD pipelines. An example is to allow updating of the template in multiple projects through the use of a variable as below.

include:
  project: 'my-group/ci-pipelines'
  ref: $PIPELINE_TEMPLATE_REF
  file: 'templates/main.yml'
Enter fullscreen mode Exit fullscreen mode
An example of a variable inside the include keyword.

A DevOps engineer could just update the $PIPELINE_TEMPLATE_REF variable in the group CI variables and all projects would use the new version of the template. Incredible, right? 🤩

Stageless pipelines

One of the main features of this version is the ability to define a pipeline without stages. For some pipelines, this will also add clarity as the relationships between each job will be explicit , instead of being implicit. It should be easier now to introduce GitLab pipelines to newcomers. 🌚

For some pipelines, it doesn't make sense to define stages. In this one, all jobs are independent of each other.

This feature should make to way to remove completely stagesin GitLab CI. Long live to directed acyclic graphs!😀

Add pronunciation to GitLab profile page

I'm still don't know how to write the pronunciation, but at least I tried. 🤓

I don't know about you, but the number of people who mispronouncing my name is too high for my liking. 😅

This feature will be especially useful in helping us learn how to pronounce the names of newcomers. It's the least we can do, right? 👍

Display local time on user’s profile

I still have two hours before my bedtime and I'm currently writing this post. 😉

If you working with people in different time zones, it could help you not to wait for someone else to answer if it's late where they are. If it is past my bedtime at 10 PM, don't expect an answer from me, I should be sleeping. 😴

GitLab 14.3

Include GitLab CI/CD configuration based on conditions

By adding rules to the include keyword, we can now only define one .gitlab-ci.yml and include some of its parts if certain conditions are met.

# file: /templates/common.gitlab-ci.yml
variables:
  __TEMPLATES_COMMON_YML__ : true

# file: /templates/docker/build.gitlab-ci.yml"
include:
  - local: "/templates/common.gitlab-ci.yml"
    rules:
      - if: $ __TEMPLATES_COMMON_YML__
Enter fullscreen mode Exit fullscreen mode
The build.gitlab-ci.yml file will include the other file only if the $ __TEMPLATES_COMMON_YML__ variable is evaluated to true.

I hope this will also allow us to include another template if the project contains some files.

Imagine, instead of manually updating each .gitlab-ci.yml file to add hadolint when a repository contains a Docker file, you could simply add your common pipeline and the repository pipeline would build itself! 😲

This is definitively something that I will be trying soon! ⌛

Use variables in other variables

Everyone loves inception, right? I'm sure this new functionality will also help us develop and maintain our pipelines as well. ♾️

job:
  variables:
    FLAGS: '-al'
    LS_CMD: 'ls "$FLAGS"'
  script:
    - 'eval "$LS_CMD"' # Executes 'ls -al'
Enter fullscreen mode Exit fullscreen mode
An example from the documentation.

Support merging CI/CD rules arrays with !reference

I started to use the new !reference keyword after it was introduced, but I remember that I quickly ran into one of its limitations: we couldn't use it with the rules keyword. It is now a thing of the past! 🌟

.no_schedule:
  rules:
    - if: $CI_PIPELINE_SOURCE == "schedule"
      when: never
    - when: on_success

job1:
  image: alpine:latest
  rules:
    - !reference [.no_schedule, rules]
  script:
      - echo "run except schedules and tags"
Enter fullscreen mode Exit fullscreen mode
An example that reported a syntax error in previous versions of GitLab.

So, that's it, the latest versions of GitLab have revealed us the new improvements. I look forward to trying them. 🤗

Discussion (0)