description_templates.md 6,9 КБ
Newer Older
GitLab Bot's avatar
GitLab Bot включено в состав коммита
1
2
3
4
5
6
---
stage: Plan
group: Project Management
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#designated-technical-writers
---

Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
7
8
# Description templates

GitLab Bot's avatar
GitLab Bot включено в состав коммита
9
>[Introduced](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/4981) in GitLab 8.11.
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
10

Marcel Amirault's avatar
Marcel Amirault включено в состав коммита
11
12
13
We all know that a properly submitted issue is more likely to be addressed in
a timely manner by the developers of a project.

Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
14
Description templates allow you to define context-specific templates for issue
Marcel Amirault's avatar
Marcel Amirault включено в состав коммита
15
16
and merge request description fields for your project, as well as help filter
out a lot of unnecessary noise from issues.
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
17
18
19
20
21
22
23
24
25
26
27
28
29
30

## Overview

By using the description templates, users that create a new issue or merge
request can select a description template to help them communicate with other
contributors effectively.

Every GitLab project can define its own set of description templates as they
are added to the root directory of a GitLab project's repository.

Description templates must be written in [Markdown](../markdown.md) and stored
in your project's repository under a directory named `.gitlab`. Only the
templates of the default branch will be taken into account.

Marcel Amirault's avatar
Marcel Amirault включено в состав коммита
31
32
33
## Use-cases

- Add a template to be used in every issue for a specific project,
Evan Read's avatar
Evan Read включено в состав коммита
34
35
  giving instructions and guidelines, requiring for information specific to that subject.
  For example, if you have a project for tracking new blog posts, you can require the
GitLab Bot's avatar
GitLab Bot включено в состав коммита
36
  title, outlines, author name, author social media information, and so on.
Marcel Amirault's avatar
Marcel Amirault включено в состав коммита
37
- Following the previous example, you can make a template for every MR submitted
GitLab Bot's avatar
GitLab Bot включено в состав коммита
38
  with a new blog post, requiring information about the post date, front matter data,
GitLab Bot's avatar
GitLab Bot включено в состав коммита
39
  images guidelines, link to the related issue, reviewer name, and so on.
Marcel Amirault's avatar
Marcel Amirault включено в состав коммита
40
- You can also create issues and merge request templates for different
GitLab Bot's avatar
GitLab Bot включено в состав коммита
41
  stages of your workflow, for example, feature proposal, feature improvement, or a bug report.
Marcel Amirault's avatar
Marcel Amirault включено в состав коммита
42

Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
43
44
45
46
47
## Creating issue templates

Create a new Markdown (`.md`) file inside the `.gitlab/issue_templates/`
directory in your repository. Commit and push to your default branch.

GitLab Bot's avatar
GitLab Bot включено в состав коммита
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
To create a Markdown file:

 1. Click the `+` button next to `master` and click **New file**.
 1. Add the name of your issue template to the **File name** text field next to `master`.
    Make sure words are separated with underscores and that your file has the `.md` extension, for
    example `feature_request.md`.
 1. Commit and push to your default branch.

If you don't have a `.gitlab/issue_templates` directory in your repository, you'll need to create it.

To create the `.gitlab/issue_templates` directory:

 1. Click the `+` button next to `master` and select **New directory**.
 1. Name this new directory `.gitlab` and commit to your default branch.
 1. Click the `+` button next to `master` again and select **New directory**.This time, n
 1. Name your directory `issue_templates` and commit to your default branch.

To check if this has worked correctly, [create a new issue](./issues/managing_issues.md#create-a-new-issue)
and see if you can choose a description template.

Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
68
69
70
71
72
73
74
75
## Creating merge request templates

Similarly to issue templates, create a new Markdown (`.md`) file inside the
`.gitlab/merge_request_templates/` directory in your repository. Commit and
push to your default branch.

## Using the templates

Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
76
77
78
79
80
Let's take for example that you've created the file `.gitlab/issue_templates/Bug.md`.
This will enable the `Bug` dropdown option when creating or editing issues. When
`Bug` is selected, the content from the `Bug.md` template file will be copied
to the issue description field. The 'Reset template' button will discard any
changes you made after picking the template and return it to its initial status.
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
81
82
83

![Description templates](img/description_templates.png)

GitLab Bot's avatar
GitLab Bot включено в состав коммита
84
## Setting a default template for merge requests and issues **(STARTER)**
Marcel Amirault's avatar
Marcel Amirault включено в состав коммита
85

GitLab Bot's avatar
GitLab Bot включено в состав коммита
86
87
88
> - This feature was introduced before [description templates](#overview) and is available in [GitLab Starter](https://about.gitlab.com/pricing/). It can be enabled in the project's settings.
> - Templates for issues were [introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/28) in GitLab EE 8.1.
> - Templates for merge requests were [introduced](https://gitlab.com/gitlab-org/gitlab/commit/7478ece8b48e80782b5465b96c79f85cc91d391b) in GitLab EE 6.9.
Marcel Amirault's avatar
Marcel Amirault включено в состав коммита
89
90

The visibility of issues and/or merge requests should be set to either "Everyone
Seth Berger's avatar
Seth Berger включено в состав коммита
91
with access" or "Only Project Members" in your project's **Settings / Visibility, project features, permissions** section, otherwise the
Marcel Amirault's avatar
Marcel Amirault включено в состав коммита
92
93
94
template text areas won't show. This is the default behavior so in most cases
you should be fine.

GitLab Bot's avatar
GitLab Bot включено в состав коммита
95
96
97
98
99
100
101
1. Go to your project's **Settings**.
1. Click **Expand** under the **Merge requests** header.
1. Fill in the **Default description template for merge requests** text area.
1. Click **Expand** under **Default issue template**.
1. Fill in the **Default description template for issues** text area.
   Since GitLab merge request and issues support [Markdown](../markdown.md), you can use it to format
   headings, lists, and so on.
Marcel Amirault's avatar
Marcel Amirault включено в состав коммита
102

Seth Berger's avatar
Seth Berger включено в состав коммита
103
![Default merge request description templates](img/description_templates_merge_request_settings.png)
GitLab Bot's avatar
GitLab Bot включено в состав коммита
104

Seth Berger's avatar
Seth Berger включено в состав коммита
105
![Default issue description templates](img/description_templates_issue_settings.png)
Marcel Amirault's avatar
Marcel Amirault включено в состав коммита
106
107

After you add the description, hit **Save changes** for the settings to take
Seth Berger's avatar
Seth Berger включено в состав коммита
108
effect. Now, every time a new merge request or issue is created, it will be
Marcel Amirault's avatar
Marcel Amirault включено в состав коммита
109
110
pre-filled with the text you entered in the template(s).

Mark Fletcher's avatar
Mark Fletcher включено в состав коммита
111
112
## Description template example

GitLab Bot's avatar
GitLab Bot включено в состав коммита
113
114
115
We make use of Description Templates for Issues and Merge Requests within the GitLab Community
Edition project. Please refer to the [`.gitlab` folder](https://gitlab.com/gitlab-org/gitlab/tree/master/.gitlab)
for some examples.
Mark Fletcher's avatar
Mark Fletcher включено в состав коммита
116

GitLab Bot's avatar
GitLab Bot включено в состав коммита
117
118
119
120
TIP: **Tip:**
It's possible to use [quick actions](quick_actions.md) within description templates to quickly add
labels, assignees, and milestones. The quick actions will only be executed if the user submitting
the issue or merge request has the permissions to perform the relevant actions.
Mark Fletcher's avatar
Mark Fletcher включено в состав коммита
121

GitLab Bot's avatar
GitLab Bot включено в состав коммита
122
Here is an example of a Bug report template:
Mark Fletcher's avatar
Mark Fletcher включено в состав коммита
123

GitLab Bot's avatar
GitLab Bot включено в состав коммита
124
```plaintext
Mark Fletcher's avatar
Mark Fletcher включено в состав коммита
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
Summary

(Summarize the bug encountered concisely)


Steps to reproduce

(How one can reproduce the issue - this is very important)


Example Project

(If possible, please create an example project here on GitLab.com that exhibits the problematic behaviour, and link to it here in the bug report)

(If you are using an older version of GitLab, this will also determine whether the bug has been fixed in a more recent version)


What is the current bug behavior?

(What actually happens)


What is the expected correct behavior?

(What you should see instead)


Relevant logs and/or screenshots

(Paste any relevant logs - please use code blocks (```) to format console output,
logs, and code as it's very hard to read otherwise.)


Possible fixes

(If you can, link to the line of code that might be responsible for the problem)

/label ~bug ~reproduced ~needs-investigation
/cc @project-manager
/assign @qa-tester
```