Copy CI variables with custom project templates
Problem to solve
GitLab 11.2 introduced instance-level custom project templates. New projects can be created with templates defined by repositories in a specified group. Information is copied over to new projects using GitLab's project import/export functionality. This does not include CI/CD variables defined in the project.
I've created several template projects for use as custom project templates to start new projects. These template projects use CI pipelines extended from Auto DevOps, and have CI/CD variables preset to match.
For example, I have a custom Angular template project that disables the
test job in Auto DevOps in favour of a set of custom CI jobs to specifically run
ng test and
ng e2e. The template project has
1 defined in its CI variables.
When a new project is created from the template, the CI variables are not copied over. This matches the project import/export documentation which states the following are NOT exported.
- Build traces and artifacts
- Container registry images
- CI variables
- Any encrypted tokens
The missing CI variables means that the project created from a template is not ready to use as is. Users have to manually find the source of the template project, and copy over CI variables. This is difficult because:
- Users might not know which group has been configured as the source for custom templates,
- Users might not have access to see the CI variables in the source template project, and
- Users might not realize they are missing CI variables meant to go with the custom project template.
The custom project template functionality should have the ability to copy CI variables. Perhaps this can be a configurable option in admin settings, alongside the configuration of which group to use for project templates.
What does success look like, and how can we measure that?
A project started from a custom template should automatically have CI variables from the source template project. In my example, users should not need to manually copy CI variables for their CI pipelines to work as intended.