What are GitLab badges?
Tags: gitlab, codequality, github, git
Published: 2020-11-06 00:22:42

---
title: What are GitLab badges?
published: true
date: 2020-11-06 00:15:00 UTC
tags: gitlab, codequality, github, git
canonical_url: https://www.benjaminrancourt.ca/what-are-gitlab-badges
cover_image: https://www.benjaminrancourt.ca/temp/gitlab-badges-rocks.jpeg
---
In one of my previous posts, [_Introduction to badges_](https://dev.to/ranb2002/introduction-to-badges-2eig), I (obviously) introduce you to the concept of repositories badges, but did you know that GitLab offers a similar concept named [**GitLab badges**](https://gitlab.com/help/user/project/badges)?

Unlike normal badges, these appear at the **top** of the project overview detail page, just below the repository’s description.

![](https://www.benjaminrancourt.ca/temp/2020-10-09-header-gitlab-repository-example.jpeg)<figcaption>Header of a repository with GitLab badges</figcaption>

They are defined by repository **configuration** , in _Settings_ → _General_ → _Badges_.

![](https://www.benjaminrancourt.ca/temp/2020-10-02-gitlab-badges-add-section.jpeg)<figcaption>Screenshot of the Badges configuration in a GitLab repository</figcaption>

Unlike normal badges, where only the image URL was mandatory, GitLab badges also require a link. In the case where a link does not make any sense, you can put the repository URL to satisfy this constraint. 🔗

## Group badges

If your projects are all under a group, you can also specify **group badges** that will be **inherited** by all projects. If your organization has an inheritance of groups, the real value of group badges will be revealed, as you can apply a badge to all repositories **recursively**. You will not need anymore to edit a dozen repositories to add the same badge!

You may have some badges that can be applied to all projects, or you can also specify some general badge, like one of my favourites: _Pipeline status_.

### Pipeline status badge

If your projects use [GitLab CI](https://docs.gitlab.com/ee/ci/), you can quickly add a badge to display the **status** of the **latest pipeline**. By using **placeholders** , the badges will even be computed by GitLab correctly for each of your projects.

- **Name** : Pipeline
- **Link** : https://gitlab.com/%{project\_path}/-/pipelines?page=1&scope=branches&ref=%{default\_branch}
- **Badge image URL** : https://gitlab.com/%{project\_path}/badges/%{default\_branch}/pipeline.svg

By using these settings, you will not see an image on your group badges, but, if you navigate to a repository of the same group, all the badge properties will be computed correctly and you will be able to see the badge.

If you click on it, you will be sent to the _Pipelines page_, where you will be able to see the latest pipeline for your default branch. 🎉

![](https://www.benjaminrancourt.ca/temp/2020-10-10-group-badge-on-group.jpeg)<figcaption>A group badge with placeholders, seen on a group</figcaption>

![](https://www.benjaminrancourt.ca/temp/2020-10-10-group-badge-on-repository.jpeg)<figcaption>The same group badge, seen on a repository of the same group</figcaption>

## Conclusion

If you prefer to define your badges by editing the `README.md` file, you still can, but they will not appear at the top of the repository. So, you now have two ways to define your repository badges. 🤠

What do you think of GitLab badges?