diff --git a/.changeset/real-baboons-vanish.md b/.changeset/real-baboons-vanish.md new file mode 100644 index 0000000000..93c30d8389 --- /dev/null +++ b/.changeset/real-baboons-vanish.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-jenkins': minor +--- + +Added configuration for the action column in Jenkins CI/CD table. It can be set to rebuild, view, or replay. diff --git a/plugins/jenkins/README.md b/plugins/jenkins/README.md index 2a0ec451c8..12c6a197da 100644 --- a/plugins/jenkins/README.md +++ b/plugins/jenkins/README.md @@ -86,6 +86,24 @@ spec: 8. Click the component in the catalog. You should now see Jenkins builds, and a last build result for your master build. +## Customize Action + +You can customize the action in the CI/CD table. + +| Action | Description | +| ----------------- | ----------------------- | +| rebuild (default) | Run new build with API | +| view | link to view build page | +| replay | link to start replay | + +```yaml +jenkinsPlugin.__experimentalReconfigure({ + tableAction: 'view', +}); +``` + +Customized action - view + ## Features - View all runs inside a folder diff --git a/plugins/jenkins/api-report.md b/plugins/jenkins/api-report.md index a2ae16988b..bcba48e4b2 100644 --- a/plugins/jenkins/api-report.md +++ b/plugins/jenkins/api-report.md @@ -98,7 +98,7 @@ const jenkinsPlugin: BackstagePlugin< entityContent: RouteRef; }, {}, - {} + JenkinsInputPluginOptions >; export { jenkinsPlugin }; export { jenkinsPlugin as plugin }; diff --git a/plugins/jenkins/src/assets/customize_action_view.png b/plugins/jenkins/src/assets/customize_action_view.png new file mode 100644 index 0000000000..8be43c5971 Binary files /dev/null and b/plugins/jenkins/src/assets/customize_action_view.png differ diff --git a/plugins/jenkins/src/components/BuildsPage/lib/CITable/CITable.tsx b/plugins/jenkins/src/components/BuildsPage/lib/CITable/CITable.tsx index 1bb6dbaefc..b0a8b84718 100644 --- a/plugins/jenkins/src/components/BuildsPage/lib/CITable/CITable.tsx +++ b/plugins/jenkins/src/components/BuildsPage/lib/CITable/CITable.tsx @@ -18,6 +18,7 @@ import { alertApiRef, useApi, useRouteRef } from '@backstage/core-plugin-api'; import { useEntityPermission } from '@backstage/plugin-catalog-react/alpha'; import { Box, IconButton, Tooltip, Typography } from '@material-ui/core'; import RetryIcon from '@material-ui/icons/Replay'; +import VisibilityIcon from '@material-ui/icons/Visibility'; import { default as React, useState } from 'react'; import { Project } from '../../../../api/JenkinsApi'; import JenkinsLogo from '../../../../assets/JenkinsLogo.svg'; @@ -25,6 +26,7 @@ import { buildRouteRef } from '../../../../plugin'; import { useBuilds } from '../../../useBuilds'; import { JenkinsRunStatus } from '../Status'; import { jenkinsExecutePermission } from '@backstage/plugin-jenkins-common'; +import { useJenkinsPluginOptions } from '../../../../options'; const FailCount = ({ count }: { count: number }): JSX.Element | null => { if (count !== 0) { @@ -202,6 +204,22 @@ const generatedColumns: TableColumn[] = [ } }; + const { tableAction } = useJenkinsPluginOptions(); + + if (tableAction === 'view') { + return row.lastBuild?.url ? ( + + + + ) : null; + } else if (tableAction === 'replay') { + return row.lastBuild?.url ? ( + + + + ) : null; + } + return ( <> diff --git a/plugins/jenkins/src/options.ts b/plugins/jenkins/src/options.ts new file mode 100644 index 0000000000..f78e6a75e9 --- /dev/null +++ b/plugins/jenkins/src/options.ts @@ -0,0 +1,29 @@ +/* + * Copyright 2020 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { usePluginOptions } from '@backstage/core-plugin-api/alpha'; + +export type JenkinsPluginOptions = { + tableAction: string; +}; + +/** @ignore */ +export type JenkinsInputPluginOptions = { + tableAction: string; +}; + +export const useJenkinsPluginOptions = () => + usePluginOptions(); diff --git a/plugins/jenkins/src/plugin.ts b/plugins/jenkins/src/plugin.ts index 7dbb6bfde1..ddef0a7dfd 100644 --- a/plugins/jenkins/src/plugin.ts +++ b/plugins/jenkins/src/plugin.ts @@ -25,6 +25,7 @@ import { identityApiRef, } from '@backstage/core-plugin-api'; import { JenkinsClient, jenkinsApiRef } from './api'; +import { JenkinsInputPluginOptions, JenkinsPluginOptions } from './options'; /** @public */ export const rootRouteRef = createRouteRef({ @@ -52,6 +53,14 @@ export const jenkinsPlugin = createPlugin({ routes: { entityContent: rootRouteRef, }, + __experimentalConfigure( + options?: JenkinsInputPluginOptions, + ): JenkinsPluginOptions { + const defaultOptions = { + tableAction: 'rebuild', + }; + return { ...defaultOptions, ...options }; + }, }); /** @public */