gitlabbackstage

Backstage GitLabDiscovery retrives repos, but does not store catalog entities


I am new to backstage and I am trying to retrieve with GitLabDiscovery the GitLab-Repos of my company to store them in the catalog of backstage. But it does not work and there are no results in the catalog.

Here is my configuration:

app-config.yaml:

integrations:
  gitlab:
    - host: ${GIT_LAB_BASE_URL}
    token: ${GITLAB_TOKEN}
    apiBaseUrl: https://${GITLAB_BASE_URL}/api/v4

catalog:
  rules:
    - allow: [Components, System, API, Resource, Location]
  providers:
    gitlab:
      ourId:
        host: ${GIT_LAB_BASE_URL}
        schedule:
          frequency: { minutes: 1 }
          timeout: { minutes: 3 }

packages/backend/src/plugins/catalog.ts

import { GitlabDiscoveryEntityProvider } from '@backstage/plugin-catalog-backend-module-gitlab';
import { CatalogBuilder } from '@backstage/plugin-catalog-backend';
import { ScaffolderEntitiesProcessor } from '@backstage/plugin-scaffolder-backend';
import { Router } from 'express';
import { PluginEnvironment } from '../types';

export default async function createPlugin(
  env: PluginEnvironment,
): Promise<Router> {
  const builder = await CatalogBuilder.create(env);

  builder.addEntityProvider(
    ...GitlabDiscoveryEntityProvider.fromConfig(env.config, {
      logger: env.logger,
      scheduler: env.scheduler,
    }),
  );
  
  builder.addProcessor(new ScaffolderEntitiesProcessor());
  const {processingEngine, router } = await builder.build();
  await processingEngine.start();
  return router;
}

What I have done so far:

  1. Started backstage with the command: "LOG_LEVEL=debug yarn dev". There were no errors shown.
  2. I followed the doc of Backstage. I added a gitlab provider and the necessary lines in app-config.yaml, installed the GitLabDiscoveryEntityProvider and I also register it in the catalog.ts. Result => It fetchs the right repos. I can see the json response, then I call the url in the browser. No errors shown. But, when I go to backstage, there are no results in the catalog.

Does someone has an idea? Thanks in advance!


Solution

  • I found my error. I had used the wrong GitLab token.