Cancelling the running task (executing of a scaffolder template)

Signed-off-by: Bogdan Nechyporenko <bnechyporenko@bol.com>
This commit is contained in:
Bogdan Nechyporenko
2023-03-09 15:40:47 +01:00
parent cec2e622d6
commit e27ddc36da
597 changed files with 6911 additions and 1680 deletions
@@ -58,6 +58,10 @@ It shouldn't take too long, and you'll have a success screen!
If it fails, you'll be able to click on each section to get the log from the
step that failed which can be helpful in debugging.
You can also cancel the running process. Once you clicked on button "Cancel", the abort signal
will be sent to a task and all next steps won't be executed. The current step will be cancelled
only if it supports it.
![Templating failed](../../assets/software-templates/failed.png)
## View Component in Catalog
@@ -71,7 +71,7 @@ You can also choose to define your custom action using JSON schema instead of `z
```ts title="With JSON Schema"
import { createTemplateAction } from '@backstage/plugin-scaffolder-node';
import fs from 'fs-extra';
import { writeFile } from 'fs';
export const createNewFileAction = () => {
return createTemplateAction<{ contents: string; filename: string }>({
@@ -95,9 +95,12 @@ export const createNewFileAction = () => {
},
},
async handler(ctx) {
await fs.outputFile(
const { signal } = ctx;
await writeFile(
`${ctx.workspacePath}/${ctx.input.filename}`,
ctx.input.contents,
{ signal },
_ => {},
);
},
});