diff --git a/.changeset/sour-phones-fix.md b/.changeset/sour-phones-fix.md index 41d35a0c21..d2519f2ef5 100644 --- a/.changeset/sour-phones-fix.md +++ b/.changeset/sour-phones-fix.md @@ -2,4 +2,4 @@ '@backstage/plugin-scaffolder-backend-module-gitlab': patch --- -Allow the usage of oauth tokens for the gitlab:group:ensureExists action +Updated `gitlab:group:ensureExists` action to instead use oauth client. diff --git a/plugins/scaffolder-backend-module-gitlab/src/actions/gitlabGroupEnsureExists.ts b/plugins/scaffolder-backend-module-gitlab/src/actions/gitlabGroupEnsureExists.ts index 0a270fc167..41bc5755c9 100644 --- a/plugins/scaffolder-backend-module-gitlab/src/actions/gitlabGroupEnsureExists.ts +++ b/plugins/scaffolder-backend-module-gitlab/src/actions/gitlabGroupEnsureExists.ts @@ -66,7 +66,7 @@ export const createGitlabGroupEnsureExistsAction = (options: { const api = getClient({ host, integrations, token }); let currentPath: string | null = null; - let parent: GroupSchema | null = null; + let parentId: number | null = null; for (const pathElement of path) { const fullPath: string = currentPath ? `${currentPath}/${pathElement}` @@ -79,22 +79,24 @@ export const createGitlabGroupEnsureExistsAction = (options: { ); if (!subGroup) { ctx.logger.info(`creating missing group ${fullPath}`); - parent = (await api.Groups.create( - pathElement, - pathElement, - parent - ? { - parentId: parent.id, - } - : {}, - )) as GroupSchema; + parentId = ( + await api.Groups.create( + pathElement, + pathElement, + parentId + ? { + parentId: parentId, + } + : {}, + ) + )?.id; } else { - parent = subGroup; + parentId = subGroup.id; } currentPath = fullPath; } - if (parent !== null) { - ctx.output('groupId', parent?.id); + if (parentId !== null) { + ctx.output('groupId', parentId); } }, });