Registering a Scaffolder template
Cortex's Scaffolder allows you to build a fully-automated Workflow for spinning up a new project (including repositories and libraries) and adds functionality to existing services (CI scripts, infrastructure modules, etc). Using templates, you can automatically generate the boilerplate and plumbing for projects, ensuring they follow best practices from day 0.
Templating is powered by the open source Cookiecutter project, an industry-standard tool to auto-generate boilerplate for new projects.
This page describes how to get started using the Scaffolder as a block in a Workflow. For advanced usage information, see Scaffolder advanced usage.

Looking for a quick introduction to Scaffolder? Check out the Cortex Academy "Intro to Scaffolder" course, available to all Cortex customers and POVs.
How to create a Scaffolder template
Prerequisite
Before getting started:
Make sure you have configured a Git integration with
write
access. The following integrations are available:Cortex's GitHub app is pre-configured with permissions for the Scaffolder.
Configure the GitLab access token with
write
permissions
Configure the Bitbucket token with
Repositories - admin and delete
scopes.
Configure the Azure DevOps token with
Code read, write & manage
access.
Make sure you have configured your username's identity mappings for your Git provider.
Step 1: Create a Cookiecutter template
To get started with the Scaffolder, you'll need a Cookiecutter template. You can either use an existing template or create a new one.
To get started quickly, you can use an existing open source template.
Find an open source template and clone the repo.
Open your
cookiecutter.json
file, located in the root of the template repository.In the file, add a
version
key and enter the version. This allows Cortex to track which version of the template was used to generate a given project in the Catalog. For example:
{ "project_name": "My Project", "database": ["postgres", "mysql"], "version": "0.1.2" }
Security restrictions for templates
For security reasons, for templates used on Cortex Cloud, we disable Cookiecutter hooks, network access, and any syscalls. If you get an exception when using your template, ensure it's not attempting any of these restricted actions.
These features are enabled for templates when using Cortex Server (self-hosted).
Step 2: Add the template to Cortex
You must have the Configure Scaffolder templates
permission to follow these steps.
In Cortex, navigate to Workflows from the main nav.
In the upper right corner of the page, click Register Scaffolder template.
Configure the template details:
Provider: Select which Git provider you are using.
Name: Enter a name for the template. This will be seen by developers when they create a service using the template.
Description: Add a description to help others understand the template's purpose.
Tags: Optionally, add tags to describe the template. For example, these could help developers understand whether the template is meant to be used for a specific service type, what language it uses, and more.
Under "Configuration," fill in the fields:
Git provider configuration: Enter the configuration, e.g.,
default
By default, the option Use this configuration for all git operations is enabled. When enabled, Cortex uses the selected configuration for all Git operations (e.g., fetching the template details, populating the form options, and creating the new repo or Pull Request). The form options will be filtered to only those organizations or repositories that the selected configuration has access to.
With this setting disabled, you can use a single Scaffolder template with multiple organizations/configurations. While the selected configuration must still have to access the template's repository, the remaining Git operations will be run dynamically based on the user's form selections. The Scaffolder form options will be populated using data from all configurations. Then, Cortex will automatically use a configuration with access to the selected organization (if scaffolding a new repository) or repository (if scaffolding a new PR) for all remaining Git operations.
Git URL: Enter the git URL where your template lives, e.g.
https://github.com/cortexapps/cookiecutter-employee
Subdirectory for Cookiecutter template: If your Cookiecutter template is not stored at the root of your repository, enter the subdirectory URL here.
Configuration requirements: Select one of the following:
New service. Cortex service descriptor will be generated for the service and it will be automatically added to relevant catalogs.
If you don't select this option, you will still have the option to create a service entity when running the Scaffolder.
New pull request. When enabled, the template can only be used to open pull requests against existing repositories.
Both. Enable both "New service" and "New pull request" configurations.
Neither. Disable both "New service" and "New pull request" configurations.
Visibility: When creating a new repository choose the default visibility of the repository. If you do not specify, the template defaults to setting a new repository as private.
The available options depend on the Git provider. The
Public
setting only works if the org containing the repository allows it. TheInternal
setting only works for GitHub Enterprise accounts.When running a Workflow that contains a Scaffolder block, you can configure an override to change the repo visibility.
Create cortex.yaml in git when creating a new service: When enabled, a cortex.yaml will be created in git when the Scaffolder creates a new service.
If you don't enable this setting, the entity descriptor will be added via the API.
Show README.md during Scaffolding: When enabled, the project's README.md will be displayed when inputting the variables to use while rendering the template. If there is no README.md, nothing will be shown.
Click Register Scaffolder template.
If you see a "Failed to save template" error, ensure that you have provided a valid Git URL.
Step 3: Create a Workflow with a Scaffolder step
After you have added a template to Cortex, you can start using the Scaffolder in a Workflow.
Follow the instructions in the Workflows documentation for creating a Workflow and adding a Scaffolder block.
View Scaffolder templates
View all templates available to your organization under Workflows > Scaffolders.
The template's Cortex ID (CID) can be found at the top of the page while editing the Scaffolder template:

Troubleshooting and FAQ
When running a Scaffolder and choosing from my list of Azure DevOps projects, some projects aren't appearing as expected.
This can happen if you have enabled the option Use this configuration for all git operations when configuring your template in Cortex. Disable this setting for the ability to choose from all configurations.
Last updated
Was this helpful?