Downloads a template from the given URL into the workspace, and runs cookiecutter on it.
Input Schema
| Property | Type | Description | Required |
|---|---|---|---|
| url | string | Relative path or absolute URL pointing to the directory tree to fetch | |
| values | object | - | |
| imageName | string | Specify a custom Docker image to run cookiecutter, to override the default: 'spotify/backstage-cookiecutter'. This can be used to execute cookiecutter with Template Extensions. Used only when a local cookiecutter is not found. | |
| extensions | array | Jinja2 extensions to add filters, tests, globals or extend the parser. Extensions must be installed in the container or on the host where Cookiecutter executes. See the contrib directory in Backstage's repo for more information | |
| targetPath | string | Target path within the working directory to download the contents to. | |
| copyWithoutRender | array | Avoid rendering directories and files in the template |
Output Schema
Usage Examples
Generate a Node service from a GitHub cookiecutter template
Downloads a public template from GitHub and renders it with values captured from template parameters. Use this early in a scaffold before publishing with publish:github.
steps:
- id: fetch-node-template
action: fetch:cookiecutter
input:
url: https://github.com/acme/cookiecutter-node-service
values:
project_name: ${{ parameters.componentName }}
project_slug: ${{ parameters.componentId }}
description: ${{ parameters.description }}
owner: ${{ parameters.owner }}
use_docker: true
license: Apache-2.0Render a local template into a component subdirectory
Uses a template stored alongside your Backstage templates and writes the output into a subfolder named after the component. Avoids rendering for CI and docs folders so they are copied as-is.
steps:
- id: fetch-local-cookiecutter
action: fetch:cookiecutter
input:
url: ./templates/service-cookiecutter
targetPath: ./services/${{ parameters.componentId }}
copyWithoutRender:
- .github/**
- docs/**
values:
project_name: ${{ parameters.componentName }}
project_slug: ${{ parameters.componentId }}
description: ${{ parameters.description }}
ci_provider: github-actions
include_docs: trueUse Jinja2 extensions with a custom Cookiecutter image
Runs cookiecutter with custom Jinja2 extensions by using a custom Docker image. Use this when your template relies on extra filters or globals.
steps:
- id: fetch-with-extensions
action: fetch:cookiecutter
input:
url: https://git.example.com/engineering/cookiecutter-microservice
imageName: ghcr.io/engineering/backstage-cookiecutter-extensions:1.2.3
extensions:
- jinja2_time.TimeExtension
- myorg.jinja2.slugify.SlugifyExtension
values:
project_name: ${{ parameters.componentName }}
project_slug: ${{ parameters.componentId }}
description: Service generated with time stamps
owner: ${{ parameters.owner }}
runtime: go
use_redis: falseScaffold a web app while skipping binary assets during rendering
Renders a web app template into a predictable path and skips templating for image and chart archives. This is useful when the template contains prebuilt assets.
steps:
- id: fetch-skip-binaries
action: fetch:cookiecutter
input:
url: https://github.com/acme/cookiecutter-webapp
targetPath: ./apps/${{ parameters.componentId }}
copyWithoutRender:
- assets/images/**
- static/**/*.png
- charts/**/*.tgz
values:
project_name: ${{ parameters.componentName }}
project_slug: ${{ parameters.componentId }}
description: ${{ parameters.description }}
owner: ${{ parameters.owner }}
frontend: react
backend: api
include_examples: falseFetch from an internal Git server into a workspace folder
Pulls a private template from an internal Git server and renders it into a workspace subfolder. Use this for enterprise templates before a publish step such as publish:github.
steps:
- id: fetch-internal-service
action: fetch:cookiecutter
input:
url: https://git.corp.example.com/platform/cookiecutter-service-template
targetPath: ./workspace/${{ parameters.componentId }}
values:
project_name: ${{ parameters.componentName }}
project_slug: ${{ parameters.componentId }}
description: ${{ parameters.description }}
owner: ${{ parameters.owner }}
language: python
package_name: ${{ parameters.componentId }}
deploy_to: kubernetes
include_ci: true