From eb3fd85d3e558ec77999a3ee8012407617a672cd Mon Sep 17 00:00:00 2001 From: Hasan Ozdemir <21654050+nodify-at@users.noreply.github.com> Date: Wed, 15 Dec 2021 17:33:49 +0100 Subject: [PATCH 1/5] feature: add crumbIssuer option to jenkins (optional) configuration, improve the UI to show a notification after executing the action: re-build Signed-off-by: Hasan Ozdemir <21654050+nodify-at@users.noreply.github.com> --- .changeset/twenty-tigers-smash.md | 5 ++ .changeset/twenty-tigers-ymash.md | 5 ++ plugins/jenkins-backend/api-report.md | 4 ++ .../src/service/jenkinsApi.test.ts | 13 ++++ .../jenkins-backend/src/service/jenkinsApi.ts | 1 + .../src/service/jenkinsInfoProvider.test.ts | 1 + .../src/service/jenkinsInfoProvider.ts | 8 ++- plugins/jenkins/api-report.md | 8 +-- plugins/jenkins/src/api/JenkinsApi.ts | 25 ++++---- .../BuildsPage/lib/CITable/CITable.tsx | 60 +++++++++++++++---- 10 files changed, 104 insertions(+), 26 deletions(-) create mode 100644 .changeset/twenty-tigers-smash.md create mode 100644 .changeset/twenty-tigers-ymash.md diff --git a/.changeset/twenty-tigers-smash.md b/.changeset/twenty-tigers-smash.md new file mode 100644 index 0000000000..b7b06074dd --- /dev/null +++ b/.changeset/twenty-tigers-smash.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-jenkins-backend': patch +--- + +feature: add crumbIssuer option to jenkins (optional) configuration, improve the UI to show a notification after executing the action re-build diff --git a/.changeset/twenty-tigers-ymash.md b/.changeset/twenty-tigers-ymash.md new file mode 100644 index 0000000000..609b30e0f5 --- /dev/null +++ b/.changeset/twenty-tigers-ymash.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-jenkins': patch +--- + +feature: add crumbIssuer option to jenkins (optional) configuration, improve the UI to show a notification after executing the action re-build diff --git a/plugins/jenkins-backend/api-report.md b/plugins/jenkins-backend/api-report.md index c909c54806..b8d171f9c1 100644 --- a/plugins/jenkins-backend/api-report.md +++ b/plugins/jenkins-backend/api-report.md @@ -52,6 +52,8 @@ export interface JenkinsInfo { // (undocumented) baseUrl: string; // (undocumented) + crumbIssuer?: boolean; + // (undocumented) headers?: Record; // (undocumented) jobFullName: string; @@ -77,6 +79,8 @@ export interface JenkinsInstanceConfig { // (undocumented) baseUrl: string; // (undocumented) + crumbIssuer?: boolean; + // (undocumented) name: string; // (undocumented) username: string; diff --git a/plugins/jenkins-backend/src/service/jenkinsApi.test.ts b/plugins/jenkins-backend/src/service/jenkinsApi.test.ts index 5f74259eef..a410d8ad92 100644 --- a/plugins/jenkins-backend/src/service/jenkinsApi.test.ts +++ b/plugins/jenkins-backend/src/service/jenkinsApi.test.ts @@ -411,4 +411,17 @@ describe('JenkinsApi', () => { }); expect(mockedJenkinsClient.job.build).toBeCalledWith(jobFullName); }); + + it('buildProject with crumbIssuer option', async () => { + const info: JenkinsInfo = { ...jenkinsInfo, crumbIssuer: true }; + await jenkinsApi.buildProject(info, jobFullName); + + expect(mockedJenkins).toHaveBeenCalledWith({ + baseUrl: jenkinsInfo.baseUrl, + headers: jenkinsInfo.headers, + promisify: true, + crumbIssuer: true, + }); + expect(mockedJenkinsClient.job.build).toBeCalledWith(jobFullName); + }); }); diff --git a/plugins/jenkins-backend/src/service/jenkinsApi.ts b/plugins/jenkins-backend/src/service/jenkinsApi.ts index 13705ce049..f156259f04 100644 --- a/plugins/jenkins-backend/src/service/jenkinsApi.ts +++ b/plugins/jenkins-backend/src/service/jenkinsApi.ts @@ -146,6 +146,7 @@ export class JenkinsApiImpl { baseUrl: jenkinsInfo.baseUrl, headers: jenkinsInfo.headers, promisify: true, + crumbIssuer: jenkinsInfo.crumbIssuer, }) as any; } diff --git a/plugins/jenkins-backend/src/service/jenkinsInfoProvider.test.ts b/plugins/jenkins-backend/src/service/jenkinsInfoProvider.test.ts index 08439297a7..21a2022bb3 100644 --- a/plugins/jenkins-backend/src/service/jenkinsInfoProvider.test.ts +++ b/plugins/jenkins-backend/src/service/jenkinsInfoProvider.test.ts @@ -210,6 +210,7 @@ describe('DefaultJenkinsInfoProvider', () => { expect(mockCatalog.getEntityByName).toBeCalledWith(entityRef); expect(info).toStrictEqual({ baseUrl: 'https://jenkins.example.com', + crumbIssuer: undefined, headers: { Authorization: 'Basic YmFja3N0YWdlIC0gYm90OjEyMzQ1Njc4OWFiY2RlZjAxMjM0NTY3ODlhYmNlZGYwMTI=', diff --git a/plugins/jenkins-backend/src/service/jenkinsInfoProvider.ts b/plugins/jenkins-backend/src/service/jenkinsInfoProvider.ts index 1a992e73f1..f5cb52b696 100644 --- a/plugins/jenkins-backend/src/service/jenkinsInfoProvider.ts +++ b/plugins/jenkins-backend/src/service/jenkinsInfoProvider.ts @@ -38,6 +38,7 @@ export interface JenkinsInfo { baseUrl: string; headers?: Record; jobFullName: string; // TODO: make this an array + crumbIssuer?: boolean; } export interface JenkinsInstanceConfig { @@ -45,6 +46,7 @@ export interface JenkinsInstanceConfig { baseUrl: string; username: string; apiKey: string; + crumbIssuer?: boolean; } /** @@ -70,6 +72,7 @@ export class JenkinsConfig { baseUrl: c.getString('baseUrl'), username: c.getString('username'), apiKey: c.getString('apiKey'), + crumbIssuer: c.getOptionalBoolean('crumbIssuer'), })) || []; // load unnamed default config @@ -81,6 +84,7 @@ export class JenkinsConfig { const baseUrl = jenkinsConfig.getOptionalString('baseUrl'); const username = jenkinsConfig.getOptionalString('username'); const apiKey = jenkinsConfig.getOptionalString('apiKey'); + const crumbIssuer = jenkinsConfig.getOptionalBoolean('crumbIssuer'); if (hasNamedDefault && (baseUrl || username || apiKey)) { throw new Error( @@ -98,12 +102,13 @@ export class JenkinsConfig { if (unnamedAllPresent) { const unnamedInstanceConfig = [ - { name: DEFAULT_JENKINS_NAME, baseUrl, username, apiKey }, + { name: DEFAULT_JENKINS_NAME, baseUrl, username, apiKey, crumbIssuer }, ] as { name: string; baseUrl: string; username: string; apiKey: string; + crumbIssuer: boolean; }[]; return new JenkinsConfig([ @@ -227,6 +232,7 @@ export class DefaultJenkinsInfoProvider implements JenkinsInfoProvider { Authorization: `Basic ${creds}`, }, jobFullName, + crumbIssuer: instanceConfig.crumbIssuer, }; } diff --git a/plugins/jenkins/api-report.md b/plugins/jenkins/api-report.md index f33e565d89..829256e22d 100644 --- a/plugins/jenkins/api-report.md +++ b/plugins/jenkins/api-report.md @@ -9,8 +9,8 @@ import { ApiRef } from '@backstage/core-plugin-api'; import { BackstagePlugin } from '@backstage/core-plugin-api'; import { DiscoveryApi } from '@backstage/core-plugin-api'; import { Entity } from '@backstage/catalog-model'; -import { EntityName } from '@backstage/catalog-model'; -import { EntityRef } from '@backstage/catalog-model'; +import type { EntityName } from '@backstage/catalog-model'; +import type { EntityRef } from '@backstage/catalog-model'; import { IdentityApi } from '@backstage/core-plugin-api'; import { InfoCardVariants } from '@backstage/core-components'; import { RouteRef } from '@backstage/core-plugin-api'; @@ -72,7 +72,7 @@ export interface JenkinsApi { entity: EntityName; jobFullName: string; buildNumber: string; - }): Promise; + }): Promise; } // Warning: (ae-missing-release-tag) "jenkinsApiRef" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) @@ -117,7 +117,7 @@ export class JenkinsClient implements JenkinsApi { entity: EntityName; jobFullName: string; buildNumber: string; - }): Promise; + }): Promise; } // Warning: (ae-missing-release-tag) "jenkinsPlugin" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) diff --git a/plugins/jenkins/src/api/JenkinsApi.ts b/plugins/jenkins/src/api/JenkinsApi.ts index 4b23fb4292..48e506953f 100644 --- a/plugins/jenkins/src/api/JenkinsApi.ts +++ b/plugins/jenkins/src/api/JenkinsApi.ts @@ -19,7 +19,7 @@ import { DiscoveryApi, IdentityApi, } from '@backstage/core-plugin-api'; -import { EntityName, EntityRef } from '@backstage/catalog-model'; +import type { EntityName, EntityRef } from '@backstage/catalog-model'; export const jenkinsApiRef = createApiRef({ id: 'plugin.jenkins.service2', @@ -66,7 +66,7 @@ export interface Project { inQueue: string; // added by us status: string; // == inQueue ? 'queued' : lastBuild.building ? 'running' : lastBuild.result, - onRestartClick: () => Promise; // TODO rename to handle.* ? also, should this be on lastBuild? + onRestartClick: () => Promise; // TODO rename to handle.* ? also, should this be on lastBuild? } export interface JenkinsApi { @@ -106,7 +106,7 @@ export interface JenkinsApi { entity: EntityName; jobFullName: string; buildNumber: string; - }): Promise; + }): Promise; } export class JenkinsClient implements JenkinsApi { @@ -140,7 +140,7 @@ export class JenkinsClient implements JenkinsApi { url.searchParams.append('branch', filter.branch); } - const idToken = await this.identityApi.getIdToken(); + const idToken = await this.getToken(); const response = await fetch(url.href, { method: 'GET', headers: { @@ -151,8 +151,8 @@ export class JenkinsClient implements JenkinsApi { return ( (await response.json()).projects?.map((p: Project) => ({ ...p, - onRestartClick: async () => { - await this.retry({ + onRestartClick: () => { + return this.retry({ entity, jobFullName: p.fullName, buildNumber: String(p.lastBuild.number), @@ -179,7 +179,7 @@ export class JenkinsClient implements JenkinsApi { jobFullName, )}/${encodeURIComponent(buildNumber)}`; - const idToken = await this.identityApi.getIdToken(); + const idToken = await this.getToken(); const response = await fetch(url, { method: 'GET', headers: { @@ -198,7 +198,7 @@ export class JenkinsClient implements JenkinsApi { entity: EntityName; jobFullName: string; buildNumber: string; - }): Promise { + }): Promise { const url = `${await this.discoveryApi.getBaseUrl( 'jenkins', )}/v1/entity/${encodeURIComponent(entity.namespace)}/${encodeURIComponent( @@ -207,12 +207,17 @@ export class JenkinsClient implements JenkinsApi { jobFullName, )}/${encodeURIComponent(buildNumber)}:rebuild`; - const idToken = await this.identityApi.getIdToken(); - await fetch(url, { + const idToken = await this.getToken(); + return fetch(url, { method: 'POST', headers: { ...(idToken && { Authorization: `Bearer ${idToken}` }), }, }); } + + private async getToken() { + const { token } = await this.identityApi.getCredentials(); + return token; + } } diff --git a/plugins/jenkins/src/components/BuildsPage/lib/CITable/CITable.tsx b/plugins/jenkins/src/components/BuildsPage/lib/CITable/CITable.tsx index b1eaf2c24c..e14b24912b 100644 --- a/plugins/jenkins/src/components/BuildsPage/lib/CITable/CITable.tsx +++ b/plugins/jenkins/src/components/BuildsPage/lib/CITable/CITable.tsx @@ -13,17 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import React from 'react'; -import { Box, IconButton, Link, Typography, Tooltip } from '@material-ui/core'; +import React, { useState } from 'react'; +import { Box, IconButton, Link, Tooltip, Typography } from '@material-ui/core'; import RetryIcon from '@material-ui/icons/Replay'; import JenkinsLogo from '../../../../assets/JenkinsLogo.svg'; import { Link as RouterLink } from 'react-router-dom'; import { JenkinsRunStatus } from '../Status'; import { useBuilds } from '../../../useBuilds'; import { buildRouteRef } from '../../../../plugin'; -import { Table, TableColumn } from '@backstage/core-components'; +import { Progress, Table, TableColumn } from '@backstage/core-components'; import { Project } from '../../../../api/JenkinsApi'; -import { useRouteRef } from '@backstage/core-plugin-api'; +import { alertApiRef, useApi, useRouteRef } from '@backstage/core-plugin-api'; const FailCount = ({ count }: { count: number }): JSX.Element | null => { if (count !== 0) { @@ -173,13 +173,51 @@ const generatedColumns: TableColumn[] = [ { title: 'Actions', sorting: false, - render: (row: Partial) => ( - - - - - - ), + render: (row: Partial) => { + const ActionWrapper = () => { + const [isLoadingRebuild, setIsLoadingRebuild] = useState(false); + const alertApi = useApi(alertApiRef); + + const onRebuild = async () => { + if (row.onRestartClick) { + setIsLoadingRebuild(true); + try { + const response = await row.onRestartClick(); + const body = (await response.json()) as { + error?: { message: string }; + }; + if (response.status !== 200) { + alertApi.post({ + message: `Jenkins re-build has been failed. Reason: ${body.error?.message}`, + severity: 'error', + }); + } else { + alertApi.post({ + message: 'Jenkins re-build has been successfully executed', + severity: 'success', + }); + } + } finally { + setIsLoadingRebuild(false); + } + } + }; + + return ( + + <> + {isLoadingRebuild && } + {!isLoadingRebuild && ( + + + + )} + + + ); + }; + return ; + }, width: '10%', }, ]; From 51ee84204d27eefc7d2d44fd1a7b92cc964a00bb Mon Sep 17 00:00:00 2001 From: Hasan Ozdemir <21654050+nodify-at@users.noreply.github.com> Date: Thu, 16 Dec 2021 14:05:51 +0100 Subject: [PATCH 2/5] fix typo. on changesets Signed-off-by: Hasan Ozdemir <21654050+nodify-at@users.noreply.github.com> --- .changeset/twenty-tigers-smash.md | 2 +- .changeset/twenty-tigers-ymash.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.changeset/twenty-tigers-smash.md b/.changeset/twenty-tigers-smash.md index b7b06074dd..3ad694fbba 100644 --- a/.changeset/twenty-tigers-smash.md +++ b/.changeset/twenty-tigers-smash.md @@ -2,4 +2,4 @@ '@backstage/plugin-jenkins-backend': patch --- -feature: add crumbIssuer option to jenkins (optional) configuration, improve the UI to show a notification after executing the action re-build +feature: add crumbIssuer option to Jenkins (optional) configuration, improve the UI to show a notification after executing the action re-build diff --git a/.changeset/twenty-tigers-ymash.md b/.changeset/twenty-tigers-ymash.md index 609b30e0f5..c3e03ba75d 100644 --- a/.changeset/twenty-tigers-ymash.md +++ b/.changeset/twenty-tigers-ymash.md @@ -2,4 +2,4 @@ '@backstage/plugin-jenkins': patch --- -feature: add crumbIssuer option to jenkins (optional) configuration, improve the UI to show a notification after executing the action re-build +feature: add crumbIssuer option to Jenkins (optional) configuration, improve the UI to show a notification after executing the action re-build From bc3695fe7ab6e3fbb88caf4f66ec15407e5fcee0 Mon Sep 17 00:00:00 2001 From: Hasan Ozdemir <21654050+nodify-at@users.noreply.github.com> Date: Fri, 17 Dec 2021 02:39:54 +0100 Subject: [PATCH 3/5] remobe base response model and throw an error if jenkins:rebuild fails Signed-off-by: Hasan Ozdemir <21654050+nodify-at@users.noreply.github.com> --- plugins/jenkins/src/api/JenkinsApi.ts | 14 +++++++++---- .../BuildsPage/lib/CITable/CITable.tsx | 21 +++++++++---------- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/plugins/jenkins/src/api/JenkinsApi.ts b/plugins/jenkins/src/api/JenkinsApi.ts index 48e506953f..ce63f84f13 100644 --- a/plugins/jenkins/src/api/JenkinsApi.ts +++ b/plugins/jenkins/src/api/JenkinsApi.ts @@ -20,6 +20,8 @@ import { IdentityApi, } from '@backstage/core-plugin-api'; import type { EntityName, EntityRef } from '@backstage/catalog-model'; +// eslint-disable-next-line import/no-extraneous-dependencies +import { ResponseError } from '@backstage/errors'; export const jenkinsApiRef = createApiRef({ id: 'plugin.jenkins.service2', @@ -66,7 +68,7 @@ export interface Project { inQueue: string; // added by us status: string; // == inQueue ? 'queued' : lastBuild.building ? 'running' : lastBuild.result, - onRestartClick: () => Promise; // TODO rename to handle.* ? also, should this be on lastBuild? + onRestartClick: () => Promise; // TODO rename to handle.* ? also, should this be on lastBuild? } export interface JenkinsApi { @@ -106,7 +108,7 @@ export interface JenkinsApi { entity: EntityName; jobFullName: string; buildNumber: string; - }): Promise; + }): Promise; } export class JenkinsClient implements JenkinsApi { @@ -198,7 +200,7 @@ export class JenkinsClient implements JenkinsApi { entity: EntityName; jobFullName: string; buildNumber: string; - }): Promise { + }): Promise { const url = `${await this.discoveryApi.getBaseUrl( 'jenkins', )}/v1/entity/${encodeURIComponent(entity.namespace)}/${encodeURIComponent( @@ -208,12 +210,16 @@ export class JenkinsClient implements JenkinsApi { )}/${encodeURIComponent(buildNumber)}:rebuild`; const idToken = await this.getToken(); - return fetch(url, { + const response = await fetch(url, { method: 'POST', headers: { ...(idToken && { Authorization: `Bearer ${idToken}` }), }, }); + + if (!response.ok) { + throw await ResponseError.fromResponse(response); + } } private async getToken() { diff --git a/plugins/jenkins/src/components/BuildsPage/lib/CITable/CITable.tsx b/plugins/jenkins/src/components/BuildsPage/lib/CITable/CITable.tsx index e14b24912b..cbc46248cf 100644 --- a/plugins/jenkins/src/components/BuildsPage/lib/CITable/CITable.tsx +++ b/plugins/jenkins/src/components/BuildsPage/lib/CITable/CITable.tsx @@ -24,6 +24,8 @@ import { buildRouteRef } from '../../../../plugin'; import { Progress, Table, TableColumn } from '@backstage/core-components'; import { Project } from '../../../../api/JenkinsApi'; import { alertApiRef, useApi, useRouteRef } from '@backstage/core-plugin-api'; +// eslint-disable-next-line import/no-extraneous-dependencies +import { ResponseError } from '@backstage/errors'; const FailCount = ({ count }: { count: number }): JSX.Element | null => { if (count !== 0) { @@ -182,20 +184,17 @@ const generatedColumns: TableColumn[] = [ if (row.onRestartClick) { setIsLoadingRebuild(true); try { - const response = await row.onRestartClick(); - const body = (await response.json()) as { - error?: { message: string }; - }; - if (response.status !== 200) { + await row.onRestartClick(); + alertApi.post({ + message: 'Jenkins re-build has been successfully executed', + severity: 'success', + }); + } catch (e) { + if (e instanceof ResponseError) { alertApi.post({ - message: `Jenkins re-build has been failed. Reason: ${body.error?.message}`, + message: `Jenkins re-build has been failed. Error: ${e.message}`, severity: 'error', }); - } else { - alertApi.post({ - message: 'Jenkins re-build has been successfully executed', - severity: 'success', - }); } } finally { setIsLoadingRebuild(false); From 047d92db5e185480ee7edcc9f5815f3cc8adb98e Mon Sep 17 00:00:00 2001 From: Hasan Ozdemir <21654050+nodify-at@users.noreply.github.com> Date: Fri, 17 Dec 2021 11:38:19 +0100 Subject: [PATCH 4/5] improve success and fail messages, re-generated api reports Signed-off-by: Hasan Ozdemir <21654050+nodify-at@users.noreply.github.com> --- plugins/jenkins/api-report.md | 4 ++-- .../jenkins/src/components/BuildsPage/lib/CITable/CITable.tsx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/jenkins/api-report.md b/plugins/jenkins/api-report.md index 829256e22d..a6926c1639 100644 --- a/plugins/jenkins/api-report.md +++ b/plugins/jenkins/api-report.md @@ -72,7 +72,7 @@ export interface JenkinsApi { entity: EntityName; jobFullName: string; buildNumber: string; - }): Promise; + }): Promise; } // Warning: (ae-missing-release-tag) "jenkinsApiRef" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) @@ -117,7 +117,7 @@ export class JenkinsClient implements JenkinsApi { entity: EntityName; jobFullName: string; buildNumber: string; - }): Promise; + }): Promise; } // Warning: (ae-missing-release-tag) "jenkinsPlugin" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) diff --git a/plugins/jenkins/src/components/BuildsPage/lib/CITable/CITable.tsx b/plugins/jenkins/src/components/BuildsPage/lib/CITable/CITable.tsx index cbc46248cf..34afbc7198 100644 --- a/plugins/jenkins/src/components/BuildsPage/lib/CITable/CITable.tsx +++ b/plugins/jenkins/src/components/BuildsPage/lib/CITable/CITable.tsx @@ -186,13 +186,13 @@ const generatedColumns: TableColumn[] = [ try { await row.onRestartClick(); alertApi.post({ - message: 'Jenkins re-build has been successfully executed', + message: 'Jenkins re-build has successfully executed', severity: 'success', }); } catch (e) { if (e instanceof ResponseError) { alertApi.post({ - message: `Jenkins re-build has been failed. Error: ${e.message}`, + message: `Jenkins re-build has failed. Error: ${e.message}`, severity: 'error', }); } From d03ee9e28f0c32e6ad36ddca4eb7adbe592f74ae Mon Sep 17 00:00:00 2001 From: Hasan Ozdemir <21654050+nodify-at@users.noreply.github.com> Date: Sat, 18 Dec 2021 19:10:15 +0100 Subject: [PATCH 5/5] feature: remove instanceof check from CITable, add @backstage/errors to jenkins plugin to resolve eslint related issues Signed-off-by: Hasan Ozdemir <21654050+nodify-at@users.noreply.github.com> --- plugins/jenkins/package.json | 1 + plugins/jenkins/src/api/JenkinsApi.ts | 1 - .../components/BuildsPage/lib/CITable/CITable.tsx | 12 ++++-------- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/plugins/jenkins/package.json b/plugins/jenkins/package.json index 5822a262b5..862c2cdfb3 100644 --- a/plugins/jenkins/package.json +++ b/plugins/jenkins/package.json @@ -35,6 +35,7 @@ "@backstage/catalog-model": "^0.9.7", "@backstage/core-components": "^0.8.1", "@backstage/core-plugin-api": "^0.3.1", + "@backstage/errors": "^0.1.5", "@backstage/plugin-catalog-react": "^0.6.5", "@backstage/theme": "^0.2.14", "@material-ui/core": "^4.12.2", diff --git a/plugins/jenkins/src/api/JenkinsApi.ts b/plugins/jenkins/src/api/JenkinsApi.ts index ce63f84f13..33edf0ade3 100644 --- a/plugins/jenkins/src/api/JenkinsApi.ts +++ b/plugins/jenkins/src/api/JenkinsApi.ts @@ -20,7 +20,6 @@ import { IdentityApi, } from '@backstage/core-plugin-api'; import type { EntityName, EntityRef } from '@backstage/catalog-model'; -// eslint-disable-next-line import/no-extraneous-dependencies import { ResponseError } from '@backstage/errors'; export const jenkinsApiRef = createApiRef({ diff --git a/plugins/jenkins/src/components/BuildsPage/lib/CITable/CITable.tsx b/plugins/jenkins/src/components/BuildsPage/lib/CITable/CITable.tsx index 34afbc7198..a959ba39c9 100644 --- a/plugins/jenkins/src/components/BuildsPage/lib/CITable/CITable.tsx +++ b/plugins/jenkins/src/components/BuildsPage/lib/CITable/CITable.tsx @@ -24,8 +24,6 @@ import { buildRouteRef } from '../../../../plugin'; import { Progress, Table, TableColumn } from '@backstage/core-components'; import { Project } from '../../../../api/JenkinsApi'; import { alertApiRef, useApi, useRouteRef } from '@backstage/core-plugin-api'; -// eslint-disable-next-line import/no-extraneous-dependencies -import { ResponseError } from '@backstage/errors'; const FailCount = ({ count }: { count: number }): JSX.Element | null => { if (count !== 0) { @@ -190,12 +188,10 @@ const generatedColumns: TableColumn[] = [ severity: 'success', }); } catch (e) { - if (e instanceof ResponseError) { - alertApi.post({ - message: `Jenkins re-build has failed. Error: ${e.message}`, - severity: 'error', - }); - } + alertApi.post({ + message: `Jenkins re-build has failed. Error: ${e.message}`, + severity: 'error', + }); } finally { setIsLoadingRebuild(false); }