Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Bug Report: Can't fetch template from private Gitlab repository #18226

Closed
2 tasks done
nlamirault opened this issue Jun 13, 2023 · 4 comments
Closed
2 tasks done
Labels
bug Something isn't working stale

Comments

@nlamirault
Copy link

nlamirault commented Jun 13, 2023

📜 Description

I try to create a new template for a Component.
this is the template:

---
apiVersion: scaffolder.backstage.io/v1beta3
kind: Template
metadata:
  name: system-template
  title: New System
  description: Create a System from template
  tags:
    - system
spec:
  owner: group:team-infra
  type: system

  parameters:
    - title: Provide System simple information
      required:
        - system
        - description
        - owner
        - domain
        - lifecycle
      properties:
        system:
          title: Name
          type: string
          description: Unique name of the System
          ui:field: EntityNamePicker
          ui:autofocus: true

        description:
          title: Description
          type: string
          description: Help others understand what this website is for.

        owner:
          title: Owner
          type: string
          description: Owner of the component
          ui:field: OwnerPicker
          ui:options:
            allowedKinds:
              - Group

        domain:
          title: Domain
          type: string
          description: Domain of the System
          ui:field: EntityPicker
          ui:options:
            allowedKinds:
              - Domain
            defaultKind: Domain

        lifecycle:
          title: Lifecycle
          description: 'Application lifecycle'
          type: string
          default: experimental
          enum:
            - deprecated
            - experimental
            - production

        dryRun:
          title: Only perform a dry run, don't publish anything
          type: boolean
          default: false

  steps:
    - id: fetch-template
      name: Fetch System Template
      action: fetch:template
      if: ${{ parameters.dryRun == false }}
      input:
        targetPath: ./systems
        # url: https://gitlab.com/xxxxxxxxx/deploy-tools/-/blob/feat/backstage-app/backstage/backstage/dev/skeleton/infrastructure/system
        url: ./skeleton/infrastructure/system
        values:
          system: ${{ parameters.system }}
          description: ${{ parameters.description }}
          owner: ${{ parameters.owner }}
          domain: ${{ parameters.domain }}
          lifecycle: ${{ parameters.lifecycle }}

    - id: publish
      name: Publish
      action: publish:gitlab:merge-request
      if: ${{ parameters.dryRun == false }}
      input:
        repoUrl: gitlab.com?repo=deploy-tools&owner=xxxxxxxx
        title: "[Backstage] Creating catalog-info.yaml for ${{ parameters.component }}"
        branchName: backstage/create-${{ parameters.component }}
        description: |
          # New project: ${{ parameters.component }}
          ${{ parameters.description if parameters.description }}
        targetPath: backstage/backstage/dev/components/${{ parameters.component }}
        token: ${{ secrets.GITLAB_TOKEN }}
        commitAction: create
        removeSourceBranch: true
        # assignee: ${{ parameters.assignee }}

    # - id: register
    #   name: Register Application in Catalog
    #   action: catalog:register
    #   if: ${{ parameters.dryRun !== true }}
    #   input:
    #     repoContentsUrl: ${{ steps.publish.output.repoContentsUrl }}
    #     catalogInfoPath: "/catalog-info.yaml"


    - name: Results
      if: ${{ parameters.dryRun }}
      action: debug:log
      input:
        listWorkspace: true

  output:
    links:
      - title: Go to GitOps Pull Request
        url: ${{ steps.open-pr.output.remoteUrl }}
      - title: Open in catalog
        icon: catalog
        entityRef: ${{ steps.register.output.entityRef }}

👍 Expected behavior

download the template.

👎 Actual Behavior with Screenshots

12023-06-13T09:23:28.146Z Beginning step Fetch System Template
22023-06-13T09:23:28.174Z info: Fetching template content from remote URL3
2023-06-13T09:23:29.102Z NotFoundError: Failed to read tree (archive) from https://gitlab.com/xxx/deploy-tools/-/blob/feat%2Fbackstage-app/backstage/backstage/dev/templates/skeleton/infrastructure/system, Opens in a new window, 404 Not Found4   
at _GitlabUrlReader.readTree (/app/node_modules/@backstage/backend-common/dist/index.cjs.js:2580:15)5
at runMicrotasks (<anonymous>)6
at processTicksAndRejections (node:internal/process/task_queues:96:5)7
at async UrlReaderPredicateMux.readTree (/app/node_modules/@backstage/backend-common/dist/index.cjs.js:3170:16)8
at async fetchContents (/app/node_modules/@backstage/plugin-scaffolder-backend/dist/cjs/ScaffolderEntitiesProcessor-021c5dcb.cjs.js:579:17)9
at async Object.handler (/app/node_modules/@backstage/plugin-scaffolder-backend/dist/cjs/ScaffolderEntitiesProcessor-021c5dcb.cjs.js:1020:7)10
at async NunjucksWorkflowRunner.executeStep (/app/node_modules/@backstage/plugin-scaffolder-backend/dist/cjs/ScaffolderEntitiesProcessor-021c5dcb.cjs.js:5201:7)11
at async NunjucksWorkflowRunner.execute (/app/node_modules/@backstage/plugin-scaffolder-backend/dist/cjs/ScaffolderEntitiesProcessor-021c5dcb.cjs.js:5266:9)12
at async TaskWorker.runOneTask (/app/node_modules/@backstage/plugin-scaffolder-backend/dist/cjs/ScaffolderEntitiesProcessor-021c5dcb.cjs.js:5481:26)13
at async run (/app/node_modules/p-queue/dist/index.js:163:29)

👟 Reproduction steps

Try to create a new component

📃 Provide the context for the Bug.

but if i open in a browser the URL from the console log (https://gitlab.com/xxx/deploy-tools/-/blob/feat%2Fbackstage-app/backstage/backstage/dev/templates/skeleton/infrastructure/system), it works fine

My Kubernetes pod have an environment variable GITLAB_TOKEN

🖥️ Your Environment

Backstage deployed in a Kubernetes cluster using the Helm chart.
The application works fine.

👀 Have you spent some time to check if this bug has been raised before?

  • I checked and didn't find similar issue

🏢 Have you read the Code of Conduct?

Are you willing to submit PR?

None

@nlamirault nlamirault added the bug Something isn't working label Jun 13, 2023
@nlamirault
Copy link
Author

Related to this i think: #2815
It works if my branch name does not contains a /

@freben
Copy link
Member

freben commented Jun 15, 2023

It seems from the error message that the registered URL contains the extra text , Opens in a new window at the end. Look at the end of the traceback's error message. That would for sure lead to a 404! Maybe you accidentally copy pasted it wrong?

@nlamirault
Copy link
Author

yes copy paste error.
I juste change the branch name of my code from feat/backstage-app to feat-backstage-app and templating works now.

@github-actions
Copy link
Contributor

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale label Aug 14, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Aug 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working stale
Projects
None yet
Development

No branches or pull requests

2 participants