How to Write a Backstage Software Template
A Backstage software template turns a portal form into a new repo complete with CI and a catalog entry.
Define a Template entity with parameters (the form) and steps (fetch template, publish to GitHub, register in the catalog). Developers pick it in Backstage and get a paved-road repo.
Steps
- Declare
parametersfor the fields you collect (name, owner). - Use
fetch:templateto render skeleton files. - Use
publish:githubto create the repo. - Use
catalog:registerto add it to the software catalog.
Template entity
template.yaml
apiVersion: scaffolder.backstage.io/v1beta3
kind: Template
metadata:
name: node-service
title: Node service (paved road)
spec:
parameters:
- title: Service details
required: [name, owner]
properties:
name: { type: string }
owner: { type: string }
steps:
- id: fetch
action: fetch:template
input:
url: ./skeleton
values: { name: ${{ parameters.name }} }
- id: publish
action: publish:github
input:
repoUrl: github.com?owner=my-org&repo=${{ parameters.name }}
- id: register
action: catalog:register
input:
repoContentsUrl: ${{ steps.publish.output.repoContentsUrl }}
catalogInfoPath: /catalog-info.yamlGotchas
- The
skeletondirectory must contain acatalog-info.yamlforcatalog:registerto find. - Actions like
publish:githubrequire the scaffolder to hold a token with repo-create scope.
Related guides
How to Scaffold a New Service With CI PreconfiguredGenerate a new service from a template using cookiecutter or copier so the repo ships with the paved-road CI…
How to Register a Service in the Backstage CatalogAdd a catalog-info.yaml so a service appears in the Backstage software catalog with its owner, lifecycle, and…