docs/9-platform-engineering/9.1.3-software-templates.md | ||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Software Templates provide developers with predefined configurations, standards, and best practices. The real benefit is embedding organizational standards around auditability, good testing, and CI/CD practices that tend to get fragmented when developer teams are all trying to come up with their own way to stand up a project. These templates help ensure that new applications are built with the same quality and structure, reducing setup time and minimizing errors. By using Software Templates, teams can focus more on building features rather than worrying about the foundational setup, ultimately leading to more efficient and standardized development processes.
Currently, your Backstage instance should have one example template already loaded in. This template is located in your-backstage/examples/template/template.yaml if you want to use it as reference. Read through Backstage's documentation on writing and adding Software Templates: Setting up Software Templates, Backstage Software Templates.
-
You will need to add some permissions in order to publish a new repo in your org through a template. Read up on how to update the permissions for your GitHub App here: GitHub Apps.
-
Create a template that generates a repo and give it a name different from the example template in Backstage. Verify that this template works as intended.
-
Now use that same template in a new repository and link the repo URL in the
catalog.locations
field in yourapp-config.yaml
. Give this template a unique name as well to differentiate it from the other templates.
?> According to the bottom of this page, it is theoretically possible to use a URL as a location for your template. However, the authors have had limited success with this. So if you can't get it to work, please just use a different type of location.
Among the many roles of the Scaffolder Plugin, it helps to automate the creation of new software projects or components by providing a variety of actions that can be used in Software Templates. This ensures consistency across projects and speeds up the initial setup process.
Here are some resources on built-in actions your templates can use: List of built-in actions, Built-in actions docs.
While there are quite a few built-in actions, you can also create custom actions to extend the functionality of your templates.
-
Write an action that adds a new file and contents to a repo using this guide: Writing Custom Actions.
-
Some of the generated files may call the module by something with "Acme" in the name. Change this to match the
const
variable created inexample.ts
. Much of the documentation is outdated, so importing intobackend/src/index.ts
should look something like this:
backend.add(import('./plugins/scaffolder-backend-module-test/src/actions/example'));
- Verify that you can use this custom action in your template.
- Why might it be advantageous to set the location for a template as a URL rather than a file within the repository? What are the implications for version control and collaboration?
- How do Backstage templates contribute to organizational standards and best practices, and what impact might this have on developer efficiency and collaboration?
- How can creating custom actions in Backstage enhance the development workflow?