Configuration for action column in Jenkins table

Signed-off-by: Tim Soslow <tsoslow@shutterstock.com>
This commit is contained in:
Tim Soslow
2023-05-01 12:39:54 -05:00
parent d1797f0e91
commit cf95c5137c
7 changed files with 80 additions and 1 deletions
+5
View File
@@ -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.
+18
View File
@@ -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',
});
```
<img src="./src/assets/customize_action_view.png" alt="Customized action - view"/>
## Features
- View all runs inside a folder
+1 -1
View File
@@ -98,7 +98,7 @@ const jenkinsPlugin: BackstagePlugin<
entityContent: RouteRef<undefined>;
},
{},
{}
JenkinsInputPluginOptions
>;
export { jenkinsPlugin };
export { jenkinsPlugin as plugin };
Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

@@ -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 ? (
<IconButton href={row.lastBuild.url} target="_blank">
<VisibilityIcon />
</IconButton>
) : null;
} else if (tableAction === 'replay') {
return row.lastBuild?.url ? (
<IconButton href={`${row.lastBuild.url}replay`} target="_blank">
<RetryIcon />
</IconButton>
) : null;
}
return (
<Tooltip title="Rerun build">
<>
+29
View File
@@ -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<JenkinsPluginOptions>();
+9
View File
@@ -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 */