diff --git a/.changeset/slimy-singers-return.md b/.changeset/slimy-singers-return.md new file mode 100644 index 0000000000..c5fc60aaa2 --- /dev/null +++ b/.changeset/slimy-singers-return.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-scaffolder-backend': patch +--- + +Fixed file path resolution for templates with a file location diff --git a/plugins/scaffolder-backend/src/scaffolder/tasks/TemplateConverter.ts b/plugins/scaffolder-backend/src/scaffolder/tasks/TemplateConverter.ts index 8019b676b5..7f76ac33d0 100644 --- a/plugins/scaffolder-backend/src/scaffolder/tasks/TemplateConverter.ts +++ b/plugins/scaffolder-backend/src/scaffolder/tasks/TemplateConverter.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { resolve as resolvePath } from 'path'; +import { resolve as resolvePath, dirname } from 'path'; import { JsonValue } from '@backstage/config'; import { TemplateEntityV1alpha1 } from '@backstage/catalog-model'; import { Logger } from 'winston'; @@ -39,7 +39,7 @@ export function templateEntityToSpec( let url: string; if (protocol === 'file') { - const path = resolvePath(location, template.spec.path || '.'); + const path = resolvePath(dirname(location), template.spec.path || '.'); url = `file://${path}`; } else {