You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Backstage连接自建GitLab报TypeError: fetch failed求助

Backstage与自建GitLab连接故障排查求助

我正在搭建Backstage软件模板,目标是通过用户参数触发GitLab流水线,创建指定配置的Kubernetes集群。按照Backstage Scaffolder动作文档配置了gitlab:repo:push和gitlab:trigger:pipeline动作,但连接始终失败。

已完成的操作:

  • 创建GitLab PAT并存储在.env文件,为Backstage后端添加dotenv包:yarn workspace backend add dotenv
  • 在app-config.yaml的scaffolder.secrets中配置${GITLAB_TOKEN}作为密钥,并在template.yaml中引用
  • 在package.json的yarn start脚本中添加NODE_OPTIONS=--no-node-snapshot
  • 在packages/backend/src/index.ts中导入GitLab插件包和dotenv库

配置文件片段

template.yaml 步骤配置

steps:
    - id: generate-manifest
      name: Generate cluster manifest
      action: fetch:template
      input:
        url: ./skeleton
        targetPath: .
        values:
          clusterName: ${{ parameters.clusterName }}
          clusterType: ${{ parameters.clusterType }}
          controlPlanes: ${{ parameters.controlPlanes }}
          workerNodes: ${{ parameters. workerNodes }}
          cpuPerNode: ${{ parameters.cpuPerNode }}
          storagePerNode: ${{ parameters.storagePerNode }}
    - id: trigger-pipeline
      name: Trigger GitLab pipeline
      action: gitlab:pipeline:trigger
      input:
        repoUrl: self-hosted-gitlab.company.com/projects/backstage-clusters
        projectId: 95
        tokenDescription: Pipeline token for Backstage application access (gitlab:pipeline:trigger)
        token: ${{ secrets.pipelineToken }}
        branch: main
        variables:
          clusterName: ${{ parameters.clusterName }}
          clusterType: ${{ parameters.clusterType }}
          controlPlanes: ${{ String(parameters.controlPlanes) }}
          workerNodes: ${{ String(parameters. workerNodes) }}
          cpuPerNode: ${{ String(parameters.cpuPerNode) }}
          storagePerNode: ${{ String(parameters.storagePerNode) }}
    - id: push-manifest
      name: Commit cluster manifest to GitLab
      action: gitlab:repo:push
      input:
        repoUrl: self-hosted-gitlab.company.com/projects/backstage-clusters
        branchName: main
        commitMessage: "Add new cluster manifest for ${{ parameters.clusterName }}"
        sourcePath: .
        targetPath: clusters/${{ parameters.clusterName }}/manifest.yaml
        token: ${{ secrets.gitlabToken }}
        commitAction: update

app-config.yaml 密钥配置

gitlab:
    - host: self-hosted-gitlab.company.com
      apiBaseUrl: http://self-hosted-gitlab.company.com/api/v4
      token: ${GITLAB_TOKEN}
...
scaffolder:
  secrets:
    gitlabToken: ${GITLAB_TOKEN}

当前问题

尝试推送manifest到Git仓库、触发流水线均返回fetch failed错误。已尝试手动传入CA证书、修改repoUrl格式等操作,问题仍未解决。检查发现GitLab的PAT从未被调用,怀疑与证书有关但找不到相关排查资料,求下一步排查方案。

内容的提问来源于stack exchange,提问作者Keshav

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.12 19:45:06