Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions workspaces/jenkins/.changeset/kind-crabs-enjoy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@backstage-community/plugin-jenkins-backend': major
'@backstage-community/plugin-jenkins': major
---

Drops support for old backend system which includes removing exports for JenkinsBuilder. Please migrate to the new backend system way of installing the plugin.
3 changes: 2 additions & 1 deletion workspaces/jenkins/bcp.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"autoVersionBump": true,
"knipReports": false
"knipReports": false,
"listDeprecations": true
}
2 changes: 1 addition & 1 deletion workspaces/jenkins/packages/app-next/src/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe('App', () => {
};

const { default: app } = await import('./App');
const rendered = await renderWithEffects(app);
const rendered = await renderWithEffects(app.createRoot());
expect(rendered.baseElement).toBeInTheDocument();
});
});
4 changes: 1 addition & 3 deletions workspaces/jenkins/packages/app-next/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const scmIntegrationsApi = ApiBlueprint.make({
}),
});

export const app = createApp({
export default createApp({
features: [
catalogPlugin,
catalogImportPlugin,
Expand All @@ -77,5 +77,3 @@ export const app = createApp({
}),
],
});

export default app.createRoot();
6 changes: 3 additions & 3 deletions workspaces/jenkins/packages/app-next/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/
import '@backstage/cli/asset-types';
import ReactDOM from 'react-dom';
import app from './App';
import ReactDOM from 'react-dom/client';
import App from './App';

ReactDOM.render(app, document.getElementById('root'));
ReactDOM.createRoot(document.getElementById('root')!).render(App.createRoot());
4 changes: 2 additions & 2 deletions workspaces/jenkins/plugins/jenkins-backend/report.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { AuthService } from '@backstage/backend-plugin-api';
import { BackendFeature } from '@backstage/backend-plugin-api';
import { BackstageCredentials } from '@backstage/backend-plugin-api';
import { CatalogApi } from '@backstage/catalog-client';
import { CatalogService } from '@backstage/plugin-catalog-node';
import { CompoundEntityRef } from '@backstage/catalog-model';
import { Config } from '@backstage/config';
import { DiscoveryService } from '@backstage/backend-plugin-api';
Expand All @@ -20,7 +20,7 @@ export class DefaultJenkinsInfoProvider implements JenkinsInfoProvider {
// (undocumented)
static fromConfig(options: {
config: Config;
catalog: CatalogApi;
catalog: CatalogService;
discovery: DiscoveryService;
auth: AuthService;
httpAuth?: HttpAuthService;
Expand Down
6 changes: 5 additions & 1 deletion workspaces/jenkins/plugins/jenkins-backend/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ import {
createBackendPlugin,
} from '@backstage/backend-plugin-api';
import { DefaultJenkinsInfoProvider } from './service/jenkinsInfoProvider';
import { catalogServiceRef } from '@backstage/plugin-catalog-node/alpha';
import { catalogServiceRef } from '@backstage/plugin-catalog-node';
import { JenkinsBuilder } from './service/JenkinsBuilder';
import { jenkinsPermissions } from '@backstage-community/plugin-jenkins-common';

/**
* Jenkins backend plugin
Expand All @@ -40,6 +41,7 @@ export const jenkinsPlugin = createBackendPlugin({
discovery: coreServices.discovery,
auth: coreServices.auth,
httpAuth: coreServices.httpAuth,
permissionsRegistry: coreServices.permissionsRegistry,
},
async init({
logger,
Expand All @@ -50,6 +52,7 @@ export const jenkinsPlugin = createBackendPlugin({
discovery,
auth,
httpAuth,
permissionsRegistry,
}) {
const jenkinsInfoProvider = DefaultJenkinsInfoProvider.fromConfig({
auth,
Expand All @@ -76,6 +79,7 @@ export const jenkinsPlugin = createBackendPlugin({
});
const { router } = await builder.build();
httpRouter.use(router);
permissionsRegistry.addPermissions(jenkinsPermissions);
},
});
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ import {
} from '@backstage/backend-plugin-api';

import { Config } from '@backstage/config';
import { createPermissionIntegrationRouter } from '@backstage/plugin-permission-node';
import { jenkinsPermissions } from '@backstage-community/plugin-jenkins-common';

/** @public */
export type JenkinsBuilderReturn = Promise<{
Expand Down Expand Up @@ -110,11 +108,6 @@ export class JenkinsBuilder {

const router = Router();
router.use(express.json());
router.use(
createPermissionIntegrationRouter({
permissions: jenkinsPermissions,
}),
);

router.get(
'/v1/entity/:namespace/:kind/:name/projects',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@
* limitations under the License.
*/

import { CatalogApi } from '@backstage/catalog-client';
import { Entity, CompoundEntityRef } from '@backstage/catalog-model';
import { CatalogService } from '@backstage/plugin-catalog-node';
import {
Entity,
CompoundEntityRef,
stringifyEntityRef,
} from '@backstage/catalog-model';
import { ConfigReader } from '@backstage/config';
import {
DefaultJenkinsInfoProvider,
Expand Down Expand Up @@ -171,9 +175,9 @@ describe('JenkinsConfig', () => {
});

describe('DefaultJenkinsInfoProvider', () => {
const mockCatalog: jest.Mocked<CatalogApi> = {
const mockCatalog: jest.Mocked<CatalogService> = {
getEntityByRef: jest.fn(),
} as any as jest.Mocked<CatalogApi>;
} as any as jest.Mocked<CatalogService>;

const entityRef: CompoundEntityRef = {
kind: 'Component',
Expand Down Expand Up @@ -201,8 +205,14 @@ describe('DefaultJenkinsInfoProvider', () => {
await expect(provider.getInstance({ entityRef })).rejects.toThrow();

expect(mockCatalog.getEntityByRef).toHaveBeenCalledWith(
entityRef,
undefined,
stringifyEntityRef(entityRef),
expect.objectContaining({
credentials: expect.objectContaining({
principal: expect.objectContaining({
type: 'service',
}),
}),
}),
);
});

Expand All @@ -229,8 +239,14 @@ describe('DefaultJenkinsInfoProvider', () => {
const info: JenkinsInfo = await provider.getInstance({ entityRef });

expect(mockCatalog.getEntityByRef).toHaveBeenCalledWith(
entityRef,
undefined,
stringifyEntityRef(entityRef),
expect.objectContaining({
credentials: expect.objectContaining({
principal: expect.objectContaining({
type: 'service',
}),
}),
}),
);
expect(info).toStrictEqual({
baseUrl: 'https://jenkins.example.com',
Expand Down Expand Up @@ -270,8 +286,14 @@ describe('DefaultJenkinsInfoProvider', () => {
const info: JenkinsInfo = await provider.getInstance({ entityRef });

expect(mockCatalog.getEntityByRef).toHaveBeenCalledWith(
entityRef,
undefined,
stringifyEntityRef(entityRef),
expect.objectContaining({
credentials: expect.objectContaining({
principal: expect.objectContaining({
type: 'service',
}),
}),
}),
);
expect(info).toMatchObject({
baseUrl: 'https://jenkins.example.com',
Expand Down Expand Up @@ -310,8 +332,14 @@ describe('DefaultJenkinsInfoProvider', () => {
const info: JenkinsInfo = await provider.getInstance({ entityRef });

expect(mockCatalog.getEntityByRef).toHaveBeenCalledWith(
entityRef,
undefined,
stringifyEntityRef(entityRef),
expect.objectContaining({
credentials: expect.objectContaining({
principal: expect.objectContaining({
type: 'service',
}),
}),
}),
);
expect(info).toMatchObject({
baseUrl: 'https://jenkins.example.com',
Expand Down Expand Up @@ -350,8 +378,14 @@ describe('DefaultJenkinsInfoProvider', () => {
const info: JenkinsInfo = await provider.getInstance({ entityRef });

expect(mockCatalog.getEntityByRef).toHaveBeenCalledWith(
entityRef,
undefined,
stringifyEntityRef(entityRef),
expect.objectContaining({
credentials: expect.objectContaining({
principal: expect.objectContaining({
type: 'service',
}),
}),
}),
);
expect(info).toMatchObject({
baseUrl: 'https://jenkins-other.example.com',
Expand Down Expand Up @@ -379,8 +413,14 @@ describe('DefaultJenkinsInfoProvider', () => {
const info: JenkinsInfo = await provider.getInstance({ entityRef });

expect(mockCatalog.getEntityByRef).toHaveBeenCalledWith(
entityRef,
undefined,
stringifyEntityRef(entityRef),
expect.objectContaining({
credentials: expect.objectContaining({
principal: expect.objectContaining({
type: 'service',
}),
}),
}),
);
expect(info).toMatchObject({
baseUrl: 'https://jenkins.example.com',
Expand Down Expand Up @@ -408,8 +448,14 @@ describe('DefaultJenkinsInfoProvider', () => {
const info: JenkinsInfo = await provider.getInstance({ entityRef });

expect(mockCatalog.getEntityByRef).toHaveBeenCalledWith(
entityRef,
undefined,
stringifyEntityRef(entityRef),
expect.objectContaining({
credentials: expect.objectContaining({
principal: expect.objectContaining({
type: 'service',
}),
}),
}),
);
expect(info).toMatchObject({
baseUrl: 'https://jenkins.example.com',
Expand Down Expand Up @@ -438,8 +484,14 @@ describe('DefaultJenkinsInfoProvider', () => {
const info: JenkinsInfo = await provider.getInstance({ entityRef });

expect(mockCatalog.getEntityByRef).toHaveBeenCalledWith(
entityRef,
undefined,
stringifyEntityRef(entityRef),
expect.objectContaining({
credentials: expect.objectContaining({
principal: expect.objectContaining({
type: 'service',
}),
}),
}),
);
expect(info).toMatchObject({
baseUrl: 'https://jenkins.example.com',
Expand Down Expand Up @@ -472,8 +524,14 @@ describe('DefaultJenkinsInfoProvider', () => {
const info: JenkinsInfo = await provider.getInstance({ entityRef });

expect(mockCatalog.getEntityByRef).toHaveBeenCalledWith(
entityRef,
undefined,
stringifyEntityRef(entityRef),
expect.objectContaining({
credentials: expect.objectContaining({
principal: expect.objectContaining({
type: 'service',
}),
}),
}),
);
expect(info).toMatchObject({
baseUrl: 'https://jenkins-other.example.com',
Expand Down Expand Up @@ -507,8 +565,14 @@ describe('DefaultJenkinsInfoProvider', () => {
const info: JenkinsInfo = await provider.getInstance({ entityRef });

expect(mockCatalog.getEntityByRef).toHaveBeenCalledWith(
entityRef,
undefined,
stringifyEntityRef(entityRef),
expect.objectContaining({
credentials: expect.objectContaining({
principal: expect.objectContaining({
type: 'service',
}),
}),
}),
);
expect(info).toMatchObject({
baseUrl: 'https://jenkins-other.example.com',
Expand Down Expand Up @@ -544,8 +608,14 @@ describe('DefaultJenkinsInfoProvider', () => {
const info: JenkinsInfo = await provider.getInstance({ entityRef });

expect(mockCatalog.getEntityByRef).toHaveBeenCalledWith(
entityRef,
undefined,
stringifyEntityRef(entityRef),
expect.objectContaining({
credentials: expect.objectContaining({
principal: expect.objectContaining({
type: 'service',
}),
}),
}),
);
expect(info).toMatchObject({
baseUrl: 'https://jenkinsOverriden.example.com',
Expand Down Expand Up @@ -580,8 +650,14 @@ describe('DefaultJenkinsInfoProvider', () => {
const info: JenkinsInfo = await provider.getInstance({ entityRef });

expect(mockCatalog.getEntityByRef).toHaveBeenCalledWith(
entityRef,
undefined,
stringifyEntityRef(entityRef),
expect.objectContaining({
credentials: expect.objectContaining({
principal: expect.objectContaining({
type: 'service',
}),
}),
}),
);
expect(info).toMatchObject({
baseUrl: 'https://jenkins.example.com',
Expand Down Expand Up @@ -615,8 +691,14 @@ describe('DefaultJenkinsInfoProvider', () => {
const info: JenkinsInfo = await provider.getInstance({ entityRef });

expect(mockCatalog.getEntityByRef).toHaveBeenCalledWith(
entityRef,
undefined,
stringifyEntityRef(entityRef),
expect.objectContaining({
credentials: expect.objectContaining({
principal: expect.objectContaining({
type: 'service',
}),
}),
}),
);
expect(info).toMatchObject({
baseUrl: 'https://jenkins.example.com',
Expand Down Expand Up @@ -651,8 +733,14 @@ describe('DefaultJenkinsInfoProvider', () => {
const info: JenkinsInfo = await provider.getInstance({ entityRef });

expect(mockCatalog.getEntityByRef).toHaveBeenCalledWith(
entityRef,
undefined,
stringifyEntityRef(entityRef),
expect.objectContaining({
credentials: expect.objectContaining({
principal: expect.objectContaining({
type: 'service',
}),
}),
}),
);
expect(info).toMatchObject({
baseUrl: 'https://jenkins.example.com',
Expand Down
Loading