diff --git a/.changeset/two-plums-fail.md b/.changeset/two-plums-fail.md new file mode 100644 index 0000000000..9d976ab4b5 --- /dev/null +++ b/.changeset/two-plums-fail.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-scaffolder-backend-module-bitbucket-server': patch +--- + +Use protocol from Bitbucket Server apiBaseUrl config parameter instead of hard-coded https diff --git a/plugins/scaffolder-backend-module-bitbucket-server/src/actions/bitbucketServerPullRequest.ts b/plugins/scaffolder-backend-module-bitbucket-server/src/actions/bitbucketServerPullRequest.ts index 440e402764..fe79935a1d 100644 --- a/plugins/scaffolder-backend-module-bitbucket-server/src/actions/bitbucketServerPullRequest.ts +++ b/plugins/scaffolder-backend-module-bitbucket-server/src/actions/bitbucketServerPullRequest.ts @@ -237,6 +237,10 @@ const getDefaultBranch = async (opts: { } return defaultBranch; }; +const isApiBaseUrlHttps = (apiBaseUrl: string): boolean => { + const url = new URL(apiBaseUrl); + return url.protocol === 'https:'; +}; /** * Creates a BitbucketServer Pull Request action. * @public @@ -401,7 +405,10 @@ export function createPublishBitbucketServerPullRequestAction(options: { startPoint: latestCommit, }); - const remoteUrl = `https://${host}/scm/${project}/${repo}.git`; + const isHttps: boolean = isApiBaseUrlHttps(apiBaseUrl); + const remoteUrl = `${ + isHttps ? 'https' : 'http' + }://${host}/scm/${project}/${repo}.git`; const auth = authConfig.token ? {