How to add prefix to the repoUrl into Backstage scaffolder template?

279 views Asked by At

I have the following backstage scaffolder template file. I want to add prefix to git repo name entered by user like prefix-${{ parameters.repoUrl | parseRepoUrl }}. For it I added repoUrl property to the fetch:template action. But I got the result without prefix into Review and create section (see at screen). What is the wrong?

apiVersion: scaffolder.backstage.io/v1beta3
kind: Template
metadata:
  name: frontend
spec:
  owner: test
  type: website
  parameters:
  - title: Provide some simple information
    required:
    - component_id
    - owner
    properties:
      component_id:
        title: Name
        type: string
        description: Unique name of the component
        ui:field: EntityNamePicker
      description:
        title: Description
        type: string
        description: Help others understand what this website is for.
      project:
        title: Parent project
        type: string
        description: The parent project to contain this service
      aws_account:
        title: AWS account
        type: string
        description: AWS account number
      aws_region:
        title: AWS region
        type: string
        description: AWS region
        default: eu-west-1
      owner:
        title: Owner
        type: string
        description: Owner of the component
        ui:field: OwnerPicker
        ui:options:
          allowedKinds:
          - Group
  - title: Choose a location
    required:
    - repoUrl
    properties:
      repoUrl:
        title: Repository Location
        type: string
        ui:field: RepoUrlPicker
        ui:options:
          allowedHosts:
          - github.com
          allowedOwners:
          - team
      team:
        title: Team
        type: string
        description: Team of the repository
        ui:field: EntityPicker
        ui:options:
          catalogFilter:
            - kind: Group
              spec.type: team
  steps:
  - id: template
    name: Fetch Skeleton + Template
    action: fetch:template
    input:
      url: ./skeleton

      values:
        component_id: ${{ parameters.component_id }}
        description: ${{ parameters.description }}
        destination: ${{ parameters.repoUrl | parseRepoUrl }}
        owner: ${{ parameters.owner }}
        aws_account: ${{ parameters.aws_account }}
        aws_region: ${{ parameters.aws_region }}
        project: ${{ parameters.project }}
        repoUrl: "prefix-${{ parameters.repoUrl | parseRepoUrl }}"

  - id: publish
    name: Publish
    action: publish:github
    input:
      allowedHosts:
      - github.com
      description: This is ${{ parameters.component_id }}
      repoUrl: "prefix-${{ parameters.repoUrl | parseRepoUrl }}"
      defaultBranch: main

  - id: register
    name: Register
    action: catalog:register
    input:
      repoContentsUrl: ${{ steps.publish.output.repoContentsUrl }}
      catalogInfoPath: "/catalog-info.yaml"

  output:
    links:
    - title: Repository
      url: ${{ steps.publish.output.remoteUrl }}
    - title: Open in catalog
      icon: catalog
      entityRef: ${{ steps.register.output.entityRef }}

result

find solution of problem

1

There are 1 answers

0
Serhii Paukov On

that solution working for me:

 repoUrl: ${{ parameters.repoUrl.split("=")[0] }}=${{ parameters.repoUrl.split("=")[1] }}=prefix-${{ parameters.repoUrl.split("=") | last }}