Merge pull request #28751 from acierto/gitlabgroupensureExists-idempotent

Made gitlab:group:ensureExists action idempotent.
This commit is contained in:
Ben Lambert
2025-02-18 09:25:25 +01:00
committed by GitHub
2 changed files with 23 additions and 11 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-scaffolder-backend-module-gitlab': patch
---
Made gitlab:group:ensureExists action idempotent
@@ -90,17 +90,24 @@ export const createGitlabGroupEnsureExistsAction = (options: {
);
if (!subGroup) {
ctx.logger.info(`creating missing group ${fullPath}`);
parentId = (
await api.Groups.create(
name,
slug,
parentId
? {
parentId: parentId,
}
: {},
)
)?.id;
parentId = await ctx.checkpoint({
key: `ensure.${name}.${slug}.${parentId}`,
// eslint-disable-next-line no-loop-func
fn: async () => {
return (
await api.Groups.create(
name,
slug,
parentId
? {
parentId: parentId,
}
: {},
)
)?.id;
},
});
} else {
parentId = subGroup.id;
}