0.2.20 • Published 8 months ago

@backstage/plugin-sonarqube-backend v0.2.20

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
8 months ago

sonarqube-backend

Welcome to the sonarqube-backend backend plugin!

Integrating into a backstage instance

This plugin needs to be added to an existing backstage instance.

# From your Backstage root directory
yarn add --cwd packages/backend @backstage/plugin-sonarqube-backend

Typically, this means creating a src/plugins/sonarqube.ts file and adding a reference to it to src/index.ts in the backend package.

sonarqube.ts

import {
  createRouter,
  DefaultSonarqubeInfoProvider,
} from '@backstage/plugin-sonarqube-backend';
import { Router } from 'express';
import { PluginEnvironment } from '../types';

export default async function createPlugin(
  env: PluginEnvironment,
): Promise<Router> {
  return await createRouter({
    logger: env.logger,
    sonarqubeInfoProvider: DefaultSonarqubeInfoProvider.fromConfig(env.config),
  });
}

src/index.ts

diff --git a/packages/backend/src/index.ts b/packages/backend/src/index.ts
index 1942c36ad1..7fdc48ba24 100644
--- a/packages/backend/src/index.ts
+++ b/packages/backend/src/index.ts
@@ -50,6 +50,7 @@ import scaffolder from './plugins/scaffolder';
 import proxy from './plugins/proxy';
 import search from './plugins/search';
 import techdocs from './plugins/techdocs';
+import sonarqube from './plugins/sonarqube';
 import techInsights from './plugins/techInsights';
 import todo from './plugins/todo';
 import graphql from './plugins/graphql';
@@ -133,6 +134,7 @@ async function main() {
     createEnv('tech-insights'),
   );
   const permissionEnv = useHotMemoize(module, () => createEnv('permission'));
+  const sonarqubeEnv = useHotMemoize(module, () => createEnv('sonarqube'));

   const apiRouter = Router();
   apiRouter.use('/catalog', await catalog(catalogEnv));
@@ -152,6 +154,7 @@ async function main() {
   apiRouter.use('/badges', await badges(badgesEnv));
   apiRouter.use('/jenkins', await jenkins(jenkinsEnv));
   apiRouter.use('/permission', await permission(permissionEnv));
+  apiRouter.use('/sonarqube', await sonarqube(sonarqubeEnv));
   apiRouter.use(notFoundHandler());

   const service = createServiceBuilder(module)

This plugin must be provided with a SonarqubeInfoProvider, this is a strategy object for finding Sonarqube instances in configuration and retrieving data from an instance.

There is a standard one provided (DefaultSonarqubeInfoProvider), but the Integrator is free to build their own.

DefaultSonarqubeInfoProvider

Allows configuration of either a single or multiple global Sonarqube instances and annotating entities with the instance name. This instance name in the entities is optional, if not provided the default instance in configuration will be used. That allow to keep configuration from before multiple instances capability to keep working without changes.

Example - Single global instance

Config
sonarqube:
  baseUrl: https://sonarqube.example.com
  apiKey: 123456789abcdef0123456789abcedf012
Catalog
apiVersion: backstage.io/v1alpha1
kind: Component
metadata:
  name: backstage
  annotations:
    sonarqube.org/project-key: YOUR_INSTANCE_NAME/YOUR_PROJECT_KEY

Example - Multiple global instance

The following will look for findings at https://special-project-sonarqube.example.com for the project of key YOUR_PROJECT_KEY.

Config
sonarqube:
  instances:
    - name: default
      baseUrl: https://default-sonarqube.example.com
      apiKey: 123456789abcdef0123456789abcedf012
    - name: specialProject
      baseUrl: https://special-project-sonarqube.example.com
      apiKey: abcdef0123456789abcedf0123456789ab
Catalog
apiVersion: backstage.io/v1alpha1
kind: Component
metadata:
  name: backstage
  annotations:
    sonarqube.org/project-key: specialProject/YOUR_PROJECT_KEY

If the specialProject/ part is omitted (or replaced with default/), the Sonarqube instance of name default will be used.

The following config is an equivalent (but less clear) version of the above:

sonarqube:
  baseUrl: https://default-sonarqube.example.com
  apiKey: 123456789abcdef0123456789abcedf012
  instances:
    - name: specialProject
      baseUrl: https://special-project-sonarqube.example.com
      apiKey: abcdef0123456789abcedf0123456789ab
0.2.20

8 months ago

0.2.19

8 months ago

0.2.19-next.1

9 months ago

0.2.19-next.0

9 months ago

0.2.18

9 months ago

0.2.17

9 months ago

0.2.16

9 months ago

0.2.16-next.2

9 months ago

0.2.16-next.1

10 months ago

0.2.15

10 months ago

0.2.15-next.0

10 months ago

0.2.14

10 months ago

0.2.13

10 months ago

0.2.12

10 months ago

0.2.12-next.3

10 months ago

0.2.12-next.2

11 months ago

0.2.12-next.1

11 months ago

0.2.12-next.0

11 months ago

0.2.11

11 months ago

0.2.11-next.2

12 months ago

0.2.11-next.1

12 months ago

0.2.11-next.0

12 months ago

0.2.10

1 year ago

0.2.10-next.3

1 year ago

0.2.10-next.2

1 year ago

0.2.10-next.1

1 year ago

0.2.5-next.2

1 year ago

0.2.5-next.1

1 year ago

0.2.5-next.3

1 year ago

0.2.9-next.1

1 year ago

0.2.9-next.2

1 year ago

0.2.9-next.0

1 year ago

0.2.4-next.0

1 year ago

0.2.1-next.1

1 year ago

0.2.10-next.0

1 year ago

0.2.8-next.2

1 year ago

0.2.7-next.1

1 year ago

0.2.7-next.0

1 year ago

0.2.2-next.2

1 year ago

0.2.2-next.1

1 year ago

0.2.2-next.0

1 year ago

0.2.1

1 year ago

0.2.7

1 year ago

0.2.6

1 year ago

0.2.9

1 year ago

0.2.8

1 year ago

0.2.3

1 year ago

0.2.2

1 year ago

0.2.5

1 year ago

0.2.4

1 year ago

0.2.1-next.0

1 year ago

0.1.11-next.2

2 years ago

0.2.0

2 years ago

0.1.10-next.1

2 years ago

0.1.10

2 years ago

0.1.11-next.0

2 years ago

0.1.11-next.1

2 years ago

0.1.10-next.0

2 years ago

0.1.9

2 years ago

0.1.8-next.2

2 years ago

0.1.8-next.1

2 years ago

0.1.8-next.0

2 years ago

0.1.9-next.2

2 years ago

0.1.9-next.0

2 years ago

0.1.9-next.1

2 years ago

0.1.8

2 years ago

0.1.7

2 years ago

0.1.7-next.2

2 years ago

0.1.7-next.0

2 years ago

0.1.7-next.1

2 years ago

0.1.5-next.0

2 years ago

0.1.5-next.1

2 years ago

0.1.6

2 years ago

0.1.5

2 years ago

0.1.3-next.1

2 years ago

0.1.3-next.0

2 years ago

0.1.2

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.4-next.3

2 years ago

0.1.4-next.0

2 years ago

0.1.4-next.1

2 years ago

0.1.4-next.2

2 years ago

0.1.2-next.1

2 years ago

0.1.2-next.2

2 years ago

0.1.2-next.0

2 years ago

0.1.1-next.2

2 years ago

0.1.1-next.1

2 years ago

0.1.1-next.0

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago

0.1.0-next.0

2 years ago