Add support for placeholder variables in markdown
What does this MR do and why?
Enabled via feature flag: markdown_placeholders
Allows a user to insert placeholder variables in the markdown, which will get replaced with values upon display. The values are added in the post-processing step so that they can be displayed only if the user has access to them, and so that their values are up-to-date.
The syntax is %{PLACEHOLDER}.
| Placeholder | Example value | Description |
|---|---|---|
%{gitlab_server} |
gitlab.com |
Server of a project |
%{gitlab_pages_domain} |
pages.gitlab.com |
Domain hosting GitLab Pages |
%{project_path} |
gitlab-org/gitlab |
Path of a project including the parent groups |
%{project_name} |
gitlab |
Name of a project |
%{project_id} |
278964 |
Database ID associated with a project |
%{project_namespace} |
gitlab-org |
Project namespace of a project |
%{project_title} |
GitLab |
Title of a project |
%{group_name} |
gitlab-org |
Group of a project |
%{default_branch} |
master |
Default branch name configured for a project’s repository |
%{commit_sha} |
ad10e011ce65492322037633ebc054efde37b143 |
ID of the most recent commit to the default branch of a project’s repository |
%{latest_tag |
v17.10.7-ee |
Latest tag added to the project’s repository |
References
Screenshots or screen recordings
| Before | After |
|---|---|
How to set up and validate locally
-
enable feature flag
markdown_placeholders -
In an issue description and/or an MR description and/or comment, add the following markdown
- `%{gitlab_server}`: %{gitlab_server} - `%{gitlab_pages_domain}` : %{gitlab_pages_domain} - `%{project_path}` : %{project_path} - `%{project_title}` : %{project_title} - `%{project_name}` : %{project_name} - `%{project_id}` : %{project_id} - `%{project_namespace}` : %{project_namespace} - `%{group_name}` : %{group_name} - `%{default_branch}` : %{default_branch} - `%{commit_sha}` : %{commit_sha} - `%{latest_tag}` : %{latest_tag} ---- This should give probably an `unknown` pipeline badge: \ `` :  This should give probably an `failed` pipeline badge: \ `` :  This will give a link to the proper tag (hover over the line), but since placeholders in link text is not supported, the link text will show the placeholder names - current limitation. \ `http://%{gitlab_server}/%{project_path}/-/tags/%{latest_tag}` : http://%{gitlab_server}/%{project_path}/-/tags/%{latest_tag} -
put the same markdown in a README.md file
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Related to #14389