6.1 KiB
stage | group | info |
---|---|---|
Manage | Workspace | To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments |
Contribute a built-in project template
This page provides instructions about how to contribute a built-in project template.
To contribute a built-in project template, you must complete the following tasks:
- Create a project template for GitLab review
- Add the template SVG icon to GitLab SVGs
- Create a merge request with vendor details
You can contribute the following types of project templates:
- Enterprise: For users with GitLab Premium and above.
- Non-enterprise: For users with GitLab Free and above.
Prerequisites
To add or update an existing template, you must have the following tools installed:
wget
tar
Create a project template for review
- In your selected namespace, create a public project.
- Add the project content you want to use in the template. Do not include unnecessary assets or dependencies. For an example, see this project.
- When the project is ready for review, create an issue with a link to your project. In your issue, mention the relevant Backend Engineering Manager and Product Manager for the Templates feature.
Add the template SVG icon to GitLab SVGs
If the project template has an SVG icon, you must add it to the GitLab SVGs project before you can create a merge request with vendor details.
Create a merge request with vendor details
Before GitLab can implement the project template, you must create a merge request in gitlab-org/gitlab
that includes vendor details about the project.
-
Export the project and save the file as
<name>.tar.gz
, where<name>
is the short name of the project. Move this file to the root directory ofgitlab-org/gitlab
. -
In
gitlab-org/gitlab
, create and checkout a new branch. -
Edit the following files to include the project template:
- For non-Enterprise project templates:
-
In
lib/gitlab/project_template.rb
, add details about the template in thelocalized_templates_table
method. In the following example, the short name of the project ishugo
:ProjectTemplate.new('hugo', 'Pages/Hugo', _('Everything you need to create a GitLab Pages site using Hugo'), 'https://gitlab.com/pages/hugo', 'illustrations/logos/hugo.svg'),
If the project doesn't have an SVG icon, exclude
, 'illustrations/logos/hugo.svg'
. -
In
spec/support/helpers/project_template_test_helper.rb
, append the short name of the template in theall_templates
method. -
In
app/assets/javascripts/projects/default_project_templates.js
, add details of the template. For example:hugo: { text: s__('ProjectTemplates|Pages/Hugo'), icon: '.template-option .icon-hugo', },
If the project doesn't have an SVG icon, use
.icon-gitlab_logo
instead.
-
- For Enterprise project templates:
-
In
ee/lib/ee/gitlab/project_template.rb
, in thelocalized_ee_templates_table
method, add details about the template. For example:::Gitlab::ProjectTemplate.new('hipaa_audit_protocol', 'HIPAA Audit Protocol', _('A project containing issues for each audit inquiry in the HIPAA Audit Protocol published by the U.S. Department of Health & Human Services'), 'https://gitlab.com/gitlab-org/project-templates/hipaa-audit-protocol', 'illustrations/logos/asklepian.svg')
-
In
ee/spec/lib/gitlab/project_template_spec.rb
, add the short name of the template in the.all
test. -
In
ee/app/assets/javascripts/projects/default_project_templates.js
, add the template details. For example:hipaa_audit_protocol: { text: s__('ProjectTemplates|HIPAA Audit Protocol'), icon: '.template-option .icon-hipaa_audit_protocol', },
-
- For non-Enterprise project templates:
-
Run the following Rake task, where
<path>/<name>
is the name you gave the template inlib/gitlab/project_template.rb
:bin/rake gitlab:update_project_templates\[<path>/<name>\]
-
Regenerate
gitlab.pot
:bin/rake gettext:regenerate
-
After you run the scripts, there is one new file in
vendor/project_templates/
and four changed files. Commit all changes and push your branch to update the merge request. For an example, see this merge request.
Test your built-in project with the GitLab Development Kit
Complete the following steps to test the project template in your own GitLab Development Kit instance:
-
Run the following Rake task, where
<path>/<name>
is the name you gave the template inlib/gitlab/project_template.rb
:bin/rake gitlab:update_project_templates\[<path>/<name>\]
Contribute an improvement to an existing template
To update an existing built-in project template:
- Create a merge request in the relevant project of the
project-templates
andpages
group and mention@gitlab-org/manage/import/backend
when you are ready for a review. - If your merge request is accepted, either:
- Create an issue to ask for the template to get updated.
- Create a merge request with vendor details to update the template.