@@ -0,0 +1,7 @@
|
||||
---
|
||||
'@backstage/plugin-sonarqube': patch
|
||||
'@backstage/plugin-sonarqube-backend': patch
|
||||
'@backstage/plugin-sonarqube-react': patch
|
||||
---
|
||||
|
||||
These packages have been migrated to the [backstage/community-plugins](https://github.com/backstage/community-plugins) repository.
|
||||
@@ -1,185 +1,3 @@
|
||||
# sonarqube-backend
|
||||
# Deprecated
|
||||
|
||||
Welcome to the sonarqube-backend backend plugin!
|
||||
|
||||
## New Backend System
|
||||
|
||||
The Sonarqube backend plugin has support for the [new backend system](https://backstage.io/docs/backend-system/), here's how you can set that up:
|
||||
|
||||
In your `packages/backend/src/index.ts` make the following changes:
|
||||
|
||||
```diff
|
||||
import { createBackend } from '@backstage/backend-defaults';
|
||||
const backend = createBackend();
|
||||
// ... other feature additions
|
||||
+ backend.add(import('@backstage/plugin-sonarqube-backend'));
|
||||
backend.start();
|
||||
```
|
||||
|
||||
## Integrating into a backstage instance
|
||||
|
||||
This plugin needs to be added to an existing backstage instance.
|
||||
|
||||
```bash
|
||||
# From your Backstage root directory
|
||||
yarn --cwd packages/backend add @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
|
||||
|
||||
```typescript
|
||||
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
|
||||
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
|
||||
|
||||
```yaml
|
||||
sonarqube:
|
||||
baseUrl: https://sonarqube.example.com
|
||||
apiKey: 123456789abcdef0123456789abcedf012
|
||||
```
|
||||
|
||||
##### Catalog
|
||||
|
||||
```yaml
|
||||
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
|
||||
|
||||
```yaml
|
||||
sonarqube:
|
||||
instances:
|
||||
- name: default
|
||||
baseUrl: https://default-sonarqube.example.com
|
||||
apiKey: 123456789abcdef0123456789abcedf012
|
||||
- name: specialProject
|
||||
baseUrl: https://special-project-sonarqube.example.com
|
||||
apiKey: abcdef0123456789abcedf0123456789ab
|
||||
```
|
||||
|
||||
##### Catalog
|
||||
|
||||
```yaml
|
||||
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:
|
||||
|
||||
```yaml
|
||||
sonarqube:
|
||||
baseUrl: https://default-sonarqube.example.com
|
||||
apiKey: 123456789abcdef0123456789abcedf012
|
||||
instances:
|
||||
- name: specialProject
|
||||
baseUrl: https://special-project-sonarqube.example.com
|
||||
apiKey: abcdef0123456789abcedf0123456789ab
|
||||
```
|
||||
|
||||
#### Example - Different frontend and backend URLs
|
||||
|
||||
In some instances, you might want to use one URL for the backend and another for the frontend.
|
||||
This can be achieved by using the optional `externalBaseUrl` property in the config.
|
||||
|
||||
##### Single instance config
|
||||
|
||||
```yaml
|
||||
sonarqube:
|
||||
baseUrl: https://sonarqube-internal.example.com
|
||||
externalBaseUrl: https://sonarqube.example.com
|
||||
apiKey: 123456789abcdef0123456789abcedf012
|
||||
```
|
||||
|
||||
##### Multiple instance config
|
||||
|
||||
```yaml
|
||||
sonarqube:
|
||||
instances:
|
||||
- name: default
|
||||
baseUrl: https://default-sonarqube-internal.example.com
|
||||
externalBaseUrl: https://default-sonarqube.example.com
|
||||
apiKey: 123456789abcdef0123456789abcedf012
|
||||
- name: specialProject
|
||||
baseUrl: https://special-project-sonarqube.example.com
|
||||
apiKey: abcdef0123456789abcedf0123456789ab
|
||||
```
|
||||
|
||||
## Links
|
||||
|
||||
- [Sonarqube Frontend](../sonarqube/README.md)
|
||||
This package has been moved to the [backstage-community/plugins](https://github.com/backstage/community-plugins) repository. Migrate to using `@backstage-community/plugin-sonarqube-backend` instead.
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
"name": "@backstage/plugin-sonarqube-backend",
|
||||
"version": "0.2.19",
|
||||
"backstage": {
|
||||
"role": "backend-plugin"
|
||||
"role": "backend-plugin",
|
||||
"moved": "@backstage-community/plugin-sonarqube-backend"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public",
|
||||
@@ -49,5 +50,6 @@
|
||||
"msw": "^1.0.0",
|
||||
"supertest": "^6.2.4"
|
||||
},
|
||||
"configSchema": "config.d.ts"
|
||||
"configSchema": "config.d.ts",
|
||||
"deprecated": "This package has been moved to the backstage/community-plugins repository. You should migrate to using @backstage-community/plugin-sonarqube-backend instead."
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
# Deprecated
|
||||
|
||||
This package has been moved to the [backstage-community/plugins](https://github.com/backstage/community-plugins) repository. Migrate to using `@backstage-community/plugin-sonarqube-react` instead.
|
||||
@@ -2,7 +2,8 @@
|
||||
"name": "@backstage/plugin-sonarqube-react",
|
||||
"version": "0.1.15",
|
||||
"backstage": {
|
||||
"role": "web-library"
|
||||
"role": "web-library",
|
||||
"moved": "@backstage-community/plugin-sonarqube-react"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
@@ -56,5 +57,6 @@
|
||||
"react": "^16.13.1 || ^17.0.0 || ^18.0.0",
|
||||
"react-dom": "^16.13.1 || ^17.0.0 || ^18.0.0",
|
||||
"react-router-dom": "6.0.0-beta.0 || ^6.3.0"
|
||||
}
|
||||
},
|
||||
"deprecated": "This package has been moved to the backstage/community-plugins repository. You should migrate to using @backstage-community/plugin-sonarqube-react instead."
|
||||
}
|
||||
|
||||
@@ -1,64 +1,3 @@
|
||||
# SonarQube Plugin
|
||||
# Deprecated
|
||||
|
||||
The SonarQube Plugin displays code statistics from [SonarCloud](https://sonarcloud.io) or [SonarQube](https://sonarqube.com).
|
||||
|
||||

|
||||
|
||||
## Getting Started
|
||||
|
||||
1. Install the SonarQube Plugin:
|
||||
|
||||
```bash
|
||||
# From your Backstage root directory
|
||||
yarn --cwd packages/app add @backstage/plugin-sonarqube
|
||||
```
|
||||
|
||||
2. Add the `EntitySonarQubeCard` to the EntityPage:
|
||||
|
||||
```diff
|
||||
// packages/app/src/components/catalog/EntityPage.tsx
|
||||
+ import { EntitySonarQubeCard } from '@backstage/plugin-sonarqube';
|
||||
|
||||
...
|
||||
|
||||
const overviewContent = (
|
||||
<Grid container spacing={3} alignItems="stretch">
|
||||
<Grid item md={6}>
|
||||
<EntityAboutCard variant="gridItem" />
|
||||
</Grid>
|
||||
+ <Grid item md={6}>
|
||||
+ <EntitySonarQubeCard variant="gridItem" />
|
||||
+ </Grid>
|
||||
</Grid>
|
||||
);
|
||||
```
|
||||
|
||||
3. Run the following commands in the root folder of the project to install and compile the changes.
|
||||
|
||||
```yaml
|
||||
yarn install
|
||||
yarn tsc
|
||||
```
|
||||
|
||||
4. Add the `sonarqube.org/project-key` annotation to the `catalog-info.yaml` file of the target repo for which code quality analysis is needed.
|
||||
|
||||
```yaml
|
||||
apiVersion: backstage.io/v1alpha1
|
||||
kind: Component
|
||||
metadata:
|
||||
name: backstage
|
||||
description: |
|
||||
Backstage is an open-source developer portal that puts the developer experience first.
|
||||
annotations:
|
||||
sonarqube.org/project-key: YOUR_INSTANCE_NAME/YOUR_PROJECT_KEY
|
||||
spec:
|
||||
type: library
|
||||
owner: CNCF
|
||||
lifecycle: experimental
|
||||
```
|
||||
|
||||
`YOUR_INSTANCE_NAME/` is optional and will query the default instance if not provided.
|
||||
|
||||
## Links
|
||||
|
||||
- [Sonarqube Backend](../sonarqube-backend/README.md)
|
||||
This package has been moved to the [backstage-community/plugins](https://github.com/backstage/community-plugins) repository. Migrate to using `@backstage-community/plugin-sonarqube` instead.
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
"version": "0.7.16",
|
||||
"description": "",
|
||||
"backstage": {
|
||||
"role": "frontend-plugin"
|
||||
"role": "frontend-plugin",
|
||||
"moved": "@backstage-community/plugin-sonarqube"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public",
|
||||
@@ -69,5 +70,6 @@
|
||||
"react-dom": "^16.13.1 || ^17.0.0 || ^18.0.0",
|
||||
"react-router-dom": "6.0.0-beta.0 || ^6.3.0"
|
||||
},
|
||||
"configSchema": "config.d.ts"
|
||||
"configSchema": "config.d.ts",
|
||||
"deprecated": "This package has been moved to the backstage/community-plugins repository. You should migrate to using @backstage-community/plugin-sonarqube instead."
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user