Merge pull request #28631 from mpsanchis/mpsanchis/gitlab-migration-project-id

createGitlabProjectMigrateAction returns migration id
This commit is contained in:
Ben Lambert
2025-02-04 11:00:35 +01:00
committed by GitHub
4 changed files with 25 additions and 8 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-scaffolder-backend-module-gitlab': patch
---
`createGitlabProjectMigrateAction` can now output the `migrationId`
@@ -24,7 +24,9 @@ import yaml from 'yaml';
const mockGitlabClient = {
Migrations: {
create: jest.fn(),
create: jest.fn(() => ({
id: 0,
})),
},
};
@@ -22,7 +22,9 @@ import { createMockDirectory } from '@backstage/backend-test-utils';
const mockGitlabClient = {
Migrations: {
create: jest.fn(),
create: jest.fn(() => ({
id: 0,
})),
},
};
@@ -89,6 +89,10 @@ export const createGitlabProjectMigrateAction = (options: {
title: 'URL to the newly imported repo',
type: 'string',
},
migrationId: {
title: 'Id of the migration that imports the project',
type: 'number',
},
},
},
},
@@ -135,17 +139,21 @@ export const createGitlabProjectMigrateAction = (options: {
};
try {
await api.Migrations.create(sourceConfig, migrationEntity);
const { id: migrationId } = await api.Migrations.create(
sourceConfig,
migrationEntity,
);
ctx.output(
'importedRepoUrl',
`${destinationHost}/${destinationNamespace}/${destinationSlug}`,
);
ctx.output('migrationId', migrationId);
} catch (e: any) {
throw new InputError(
`Failed to transfer repo ${sourceFullPath}. Make sure that ${sourceFullPath} exists in ${sourceUrl}, and token has enough rights.\nError: ${e}`,
);
}
ctx.output(
'importedRepoUrl',
`${destinationHost}/${destinationNamespace}/${destinationSlug}`,
);
},
});
};