Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.

Chapter 5. Standardizing project development with software templates


As a platform engineer, you can use Software Templates in Red Hat Developer Hub (RHDH) to provide standardized project starter kits for your development teams. This self-service model improves developer productivity and ensures that new projects follow organizational standards and best practices.

5.1. Software Templates in Red Hat Developer Hub

You can use Software Templates in RHDH to automate the project setup process to reduce manual configuration and errors for developers. These Software Templates are part of the Backstage Scaffolder system.

A Software Template consists of a YAML file with the following elements:

  • Metadata: Names and describes the template so developers can find the correct starter kit in the catalog.
  • Parameters: Define the specific information developers must provide, such as the project name or owner.
  • Steps: Sequence of steps that the system performs to build the project, such as fetching a repository skeleton, injecting parameters, and publishing the code to a Git provider.

5.2. Creating a basic Software Template

To automate the setup of standardized environments for your developers, you must create a template definition. This definition allows RHDH to automate the repetitive tasks of repository creation and initial configuration.

Prerequisites

  • You have administrator access to a RHDH instance.
  • You have a Git repository to store Software Template files.

Procedure

  1. Create a directory in your Git repository for the Software Template.
  2. Create a file named template.yaml in that directory.
  3. In the template.yaml file, define the apiVersion, kind, and metadata to identify the starter kit in the software catalog.
  4. Add a spec section to define the parameters that a developer must provide when they use the Software Template.
  5. Define the steps required to generate the project, such as fetch:template to retrieve the skeleton and publish:github to create the new repository.

    Important

    You must include TechDocs in your Software Templates to ensure that documentation is automatically generated for every new project created from the Software Template.

Verification

  1. Inspect the template.yaml file to ensure the YAML syntax is valid.
  2. Confirm that the name and action fields are defined so the template is correctly recognized as a Scaffolder task.
  3. Check that the defined parameters match the variables used in your Software Template skeleton files.
  4. Navigate to the form playground at <instance-url>/create/template-form and test the Software Template configuration to confirm the fields and logic render as intended.

5.3. Sample Software Template

The following example shows a Software Template that defines project parameters and publishes the generated code to a GitHub repository.

apiVersion: scaffolder.backstage.io/v1beta3
kind: Template
metadata:
  name: basic-node-service
  title: Basic Node.js Service
  description: A starter kit for a standardized Node.js microservice.
  tags:
    - nodejs
    - recommended
spec:
  owner: platform-team
  type: service
  parameters:
    - title: ProjectDetails
      required:
        - name
        - owner
      properties:
        name:
          title: Name
          type: string
          description: Unique name for the new repository.
        owner:
          title: Owner
          type: string
          description: The group responsible for this component.
          ui:field: OwnerPicker
          ui:options:
            allowedKinds:
              - Group
  steps:
    - id: fetch-base
      name: Fetch Skeleton
      action: fetch:template
      input:
        url: ./skeleton
        values:
          name: ${{ parameters.name }}
          owner: ${{ parameters.owner }}
    - id: publish
      name: Publish to GitHub
      action: publish:github
      input:
        allowedHosts: ['github.com']
        description: This is ${{ parameters.name }}
        repoUrl: github.com?owner=my-org&repo=${{ parameters.name }}
  output:
    links:
      - title: Repository
        url: ${{ steps['publish'].output.remoteUrl }}
Copy to Clipboard Toggle word wrap

5.4. Enabling Self-service with Software Templates

To allow developers to create new projects independently using your standards, you must publish the Software Template definition to the RHDH catalog. This registration makes the template a selectable option in the software creator interface.

Prerequisites

  • You have administrator access to a RHDH instance.
  • You have a Git repository to store Software Template files.

Procedure

  1. Navigate to the Create page in the RHDH interface.
  2. Select Register Component.
  3. Enter the full URL to your template.yaml file in the Repository URL field.
  4. Click Analyze and then Import.

Verification

  1. Navigate to the Create page.
  2. Confirm that your new template appears in the list of available options.

5.5. Extending Software Templates for complex project requirements

Use advanced logic to create Software Templates that adapt to specific project requirements and user inputs. The following table outlines the goals for advanced templating:

Expand
FeatureDescription

Parameterization

Use variables to inject user-provided data into project files.

Conditional Logic

Perform specific automation steps only when certain conditions are met.

Fetch and Execute

Retrieve remote files and run commands during the setup process.

Red Hat logoGithubredditYoutubeTwitter

Lernen

Testen, kaufen und verkaufen

Communitys

Über Red Hat Dokumentation

Wir helfen Red Hat Benutzern, mit unseren Produkten und Diensten innovativ zu sein und ihre Ziele zu erreichen – mit Inhalten, denen sie vertrauen können. Entdecken Sie unsere neuesten Updates.

Mehr Inklusion in Open Source

Red Hat hat sich verpflichtet, problematische Sprache in unserem Code, unserer Dokumentation und unseren Web-Eigenschaften zu ersetzen. Weitere Einzelheiten finden Sie in Red Hat Blog.

Über Red Hat

Wir liefern gehärtete Lösungen, die es Unternehmen leichter machen, plattform- und umgebungsübergreifend zu arbeiten, vom zentralen Rechenzentrum bis zum Netzwerkrand.

Theme

© 2026 Red Hat
Nach oben