Note: GitLab 17.1 (June 2024) comes with:
New placeholders for group and project badges
You can now create badge links and image URLs using four new placeholders:
%{project_namespace}
- referencing the full path of a project namespace
%{group_name}
- referencing the group name
%{gitlab_server}
- referencing the group’s or project’s server name
%{gitlab_pages_domain}
- referencing the group’s or project’s domain name
Thank you @TamsilAmani for this community contribution!
See Documentation and Issue.
For instance, in your README.md
, you could embed the badge with dynamic linking:
[![coverage report](https://%{gitlab_server}/%{project_namespace}/%{project_path}/badges/%{default_branch}/coverage.svg)](http://%{project_namespace}.pages.%{gitlab_pages_domain}/%{project_path}/coverage/)
But, warning, the documentation does mention:
Placeholders allow badges to expose otherwise-private information, such as the default branch or commit SHA when the project is configured to have a private repository.
This behavior is intentional, as badges are intended to be used publicly.
Avoid using these placeholders if the information is sensitive.