Scaffolding Components in Backstage

Published on November 24th, 2021

Introduction

This tutorial will show you how to create a basic scaffolder template in Backstage.

Prerequisite

You must have installed the Github App in order to use the scaffolder. If you have not done this you can find the steps to do this here.

Steps

You can either follow the text or the video, or both.

Step One. Enable the scaffolder

Visit the Administration > Settings > Scaffolder and make sure the enabled check box is selected, press save and apply and restart.

Step Two. Create a template.yaml file in a repository

You can either create the following file in your own repository or use the public example we prepared.

Expand here to see an example template.yaml
apiVersion: backstage.io/v1beta2
kind: Template
# some metadata about the template itself
metadata:
  name: hello-world
  title: Hello World
  description: scaffolder Hello, World template demo
spec:
  owner: backstage/techdocs-core
  type: service

  parameters:
    - title: Fill in some steps
      required:
        - name
      properties:
        name:
          title: Name
          type: string
          description: Name of new project
          ui:autofocus: true
          ui:options:
            rows: 5

  # here's the steps that are executed in series in the scaffolder backend
  steps:
    - id: log-message
      name: Log Message
      action: debug:log
      input:
        message: "Hello, {{ parameters.name }}"

Step Three. Import the template.yaml file into backstage

Click the “Create…” button in the Backstage menu.

scaffolder-link.png

In the “Create a New Component” page, click the “Register Existing Component” button register-new-component.png

Enter the URL of the template that you created in Step Two. create-existing-component.png

Click Analyze, and Import.

Step Four. Run the template

Visit the “Create a New Component” page again by clicking the “Create…” menu item.

scaffolder-link.png

You should see the template that you have just imported. Click the choose button.

choose-template.png

Enter a the required parameters and click “Next Step” and then “Create”

enter-paramaters.png

After a couple of seconds you should see the “Task Activity” page with the output of the task.

task-activity.png

What Next?

You can see the full list of Scaffolder Tasks that we support at Roadie by visiting https://<tenant-name>.roadie.so/create/actions