diff --git a/.changeset/modern-ladybugs-perform.md b/.changeset/modern-ladybugs-perform.md new file mode 100644 index 0000000000..182b0899db --- /dev/null +++ b/.changeset/modern-ladybugs-perform.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-scaffolder-backend': minor +--- + +Scaffolding a repository in Bitbucket will now use the apiBaseUrl if it is provided instead of only the host parameter diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/bitbucket.test.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/bitbucket.test.ts index 40e7f613f2..2df8a4415d 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/bitbucket.test.ts +++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/bitbucket.test.ts @@ -37,6 +37,7 @@ describe('publish:bitbucket', () => { { host: 'hosted.bitbucket.com', token: 'thing', + apiBaseUrl: 'https://hosted.bitbucket.com/rest/api/1.0', }, { host: 'notoken.bitbucket.com', diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/bitbucket.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/bitbucket.ts index 243e515b19..cd3453adfd 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/bitbucket.ts +++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/bitbucket.ts @@ -84,6 +84,7 @@ const createBitbucketServerRepository = async (opts: { description: string; repoVisibility: 'private' | 'public'; authorization: string; + apiBaseUrl?: string; }) => { const { host, @@ -92,6 +93,7 @@ const createBitbucketServerRepository = async (opts: { description, authorization, repoVisibility, + apiBaseUrl, } = opts; let response: Response; @@ -109,10 +111,8 @@ const createBitbucketServerRepository = async (opts: { }; try { - response = await fetch( - `https://${host}/rest/api/1.0/projects/${owner}/repos`, - options, - ); + const baseUrl = apiBaseUrl ? apiBaseUrl : `https://${host}/rest/api/1.0`; + response = await fetch(`${baseUrl}/projects/${owner}/repos`, options); } catch (e) { throw new Error(`Unable to create repository, ${e}`); } @@ -223,6 +223,7 @@ export function createPublishBitbucketAction(options: { } const authorization = getAuthorizationHeader(integrationConfig.config); + const apiBaseUrl = integrationConfig.config.apiBaseUrl; const createMethod = host === 'bitbucket.org' @@ -236,6 +237,7 @@ export function createPublishBitbucketAction(options: { repo, repoVisibility, description, + apiBaseUrl, }); await initRepoAndPush({