How to Create Description Templates for Gitlab Projects

To Create Description Templates for GitLab Projects

Description template is an option available on GitLab, which allows the users to define context specific templates for an issue. Also, they are used for merging request description fields for the projects. Each and every project on GitLab 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 and stored in your project' s repository under a directory named .gitlab. Oed. As a part of our GitLab series, we have covered a tutorial related to creating a project on GitLab.

To Create a Project refer https://www.linuxhelp.com/how-to-create-a-project-in-gitlab/

In this article, let us see the method to create a Description Template for your GitLab project.

To create Description Templates

Log in to your Gitlab Server and choose the project to which you need to create a description template. Choose the Issues tab from the menu.

Click on the New Issue button.

When the New Issue page appears, click on the description template option available under the Title field.

Once it is done, log into your GitLab server via SSH, and enter your project’ s repository directory that you have already cloned while creating your project and project repository.

[root@git ~]# ls
anaconda-ks.cfg  Desktop  Documents  Downloads  initial-setup-ks.cfg  Music  Pictures  Public  sample-project  Templates  Videos
[root@git ~]# cd sample-project/
[root@git sample-project]# ls -la
total 8
drwxr-xr-x.  3 root root   33 Mar 27 02:46 .
dr-xr-x---. 17 root root 4096 Mar 27 02:45 ..
drwxr-xr-x.  8 root root 4096 Mar 27 02:47 .git
-rw-r--r--.  1 root root    0 Mar 27 02:46 README.md

Now create the .gitlab/issue_templates/ and .gitlab/merge_request_templates/ directories under your project’ s home directory.

[root@git sample-project]# mkdir -p .gitlab/issue_templates/
[root@git sample-project]# mkdir .gitlab/merge_request_templates/

Once it is done, move to .gitlab/issue_templates/ directory and create a markdown (.md) file in order to enable description templates for issues.

[root@git sample-project]# cd .gitlab/issue_templates/
[root@git issue_templates]# vim test.md

Place any content inside test.md file. And then move to /gitlab/merge_request_templates/ directory and create a markdown .md file in order to enable description templates for merge request.

[root@git issue_templates]# cd ..
[root@git .gitlab]# cd merge_request_templates/
[root@git merge_request_templates]# vim merge.md

Place any content inside merge.md file.


After creating any new file inside your project repository, commit and update the changes to git server which will enable the server to identify the new files. Once it is done, update test.md and merge.md file to git server.

[root@git sample-project]# cd .gitlab/issue_templates/
[root@git issue_templates]# ls
test.md
[root@git issue_templates]# git add test.md 
[root@git issue_templates]# git commit -m " test commit" 
[master c82ddd1] test commit
 1 file changed, 1 insertion(+)
 create mode 100644 .gitlab/issue_templates/test.md
[root@git issue_templates]# cd ..
[root@git .gitlab]# cd merge_request_templates/
[root@git merge_request_templates]# ls
merge.md
[root@git merge_request_templates]# git add merge.md 
[root@git merge_request_templates]# git commit -m " merge commit" 
[master fd7e889] merge commit
 1 file changed, 1 insertion(+)
 create mode 100644 .gitlab/merge_request_templates/merge.md

Both the files are now added to Git and are committed and ready to go. You can push those files into git using the following command.

[root@git merge_request_templates]# cd ../..
[root@git sample-project]# git push -u origin master
Password for ' http://root@192.168.5.143' : 
Counting objects: 11, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (10/10), 760 bytes | 0 bytes/s, done.
Total 10 (delta 0), reused 0 (delta 0)
To http://root@192.168.5.143/root/sample-project.git
   d490e1d..fd7e889  master ->  master

Once all these procedure is done, go to your Git WebUI and create a new issue. A new Dropdown menu for description templates appears on your screen.

You can create an issue on the template you have chosen.

Wasn' t it a simple method to create a Description Template? Stay connected to know more about various other aspects of GitLab from our future articles.

Tag : gitlab
FAQ
Q
which command to push the codes to gitlab?
A
use the following command to push the codes to gitlab
# git push -u origin master
Q
how to add the codes in git?
A
After creating any new file inside your project repository, commit and update the changes to git server which will enable the server to identify the new files. Once it is done, update test.md and merge.md file to git server.
# cd .gitlab/issue_templates/
# git add test.md
# git commit -m " test commit"
Q
where to create a new issue in gitlab?
A
Once all these procedure is done, go to your Git WebUI and create a new issue. A new Dropdown menu for description templates appears on your screen.
Q
How to create project in gitlab?
A
refer the following link for create profect in gitlab
https://www.linuxhelp.com/how-to-create-a-project-in-gitlab/
Q
How to add users im gitlab?
A
use the following link for adding the user in gitlab
https://www.linuxhelp.com/how-to-create-a-group-on-gitlab/