From 53b1b559d28bc1952d0e437c149786132f816534 Mon Sep 17 00:00:00 2001 From: Djamaile Rahamat Date: Tue, 8 Jun 2021 02:37:16 +0200 Subject: [PATCH 1/2] fix: make bitbucket publish action use apiBaseUrl if it is provided Signed-off-by: Djamaile Rahamat --- .../actions/builtin/publish/bitbucket.test.ts | 1 + .../scaffolder/actions/builtin/publish/bitbucket.ts | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) 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({ From 66c6bfebd54107a0dccce1d8469c486a4d7ecff2 Mon Sep 17 00:00:00 2001 From: Djamaile Rahamat Date: Tue, 8 Jun 2021 02:46:18 +0200 Subject: [PATCH 2/2] docs: update changelog Signed-off-by: Djamaile Rahamat --- .changeset/modern-ladybugs-perform.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/modern-ladybugs-perform.md 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