Skip to content

Add Bitbucket Cloud support - #7076

Closed
Shubhammete wants to merge 17 commits into
backstage:mainfrom
Shubhammete:main
Closed

Shubhammete wants to merge 17 commits into
backstage:mainfrom
Shubhammete:main

Conversation

@Shubhammete

Copy link
Copy Markdown
Contributor

Hey, I just made a Pull Request!

This PR adds initial support for Bitbucket Cloud to the Bitbucket Pull Requests plugin, which previously only supported Bitbucket Data Center.
Organizations using Bitbucket Cloud can now fetch and view pull requests inside Backstage using the official Bitbucket Cloud REST API, while keeping full backward compatibility with existing Data Center users.

✔️ Checklist

  • A changeset describing the change and affected packages. (more info)
  • Added or updated documentation
  • Tests for new functionality and regression tests for bug fixes
  • Screenshots attached (for UI changes)
  • All your commits have a Signed-off-by line in the message. (more info)

Fixes #6814

Shubhammete and others added 12 commits January 7, 2026 00:27
…d access bitbucket.proxyPath via config.d.ts

Signed-off-by: Shubhammete <[email protected]>
…d access bitbucket.proxyPath via config.d.ts

Signed-off-by: Shubhammete <[email protected]>
…d access bitbucket.proxyPath via config.d.ts

Signed-off-by: Shubhammete <[email protected]>
…d access bitbucket.proxyPath via config.d.ts

Signed-off-by: Shubhammete <[email protected]>
Signed-off-by: Shubhammete <[email protected]>
Signed-off-by: Shubhammete <[email protected]>
Signed-off-by: Shubhammete <[email protected]>
@Shubhammete
Shubhammete requested review from a team, mbruhin and smymoon as code owners January 27, 2026 18:28
@Shubhammete
Shubhammete requested review from Parsifal-M and removed request for a team January 27, 2026 18:28
@backstage-goalie

backstage-goalie Bot commented Jan 27, 2026 •

Copy link
Copy Markdown
Contributor

Changed Packages

Package Name Package Path Changeset Bump Current Version
@backstage-community/plugin-bitbucket-pull-requests workspaces/bitbucket-pull-requests/plugins/bitbucket-pull-requests major v3.0.3

@mbruhin mbruhin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for tackling this! I left a few comments—some of the Bitbucket Cloud endpoints/fields used here don’t appear to match the official docs, and I can’t validate the behavior locally. Please add evidence of Cloud testing (e.g., screenshots or logs) and/or tests covering the new Cloud paths before merge.

@Shubhammete

Copy link
Copy Markdown
Contributor Author

Hi @mbruhin
thanks for the review!
I’ll need a bit of time to address all of these properly and will follow up with updates on this PR once the changes are ready.

@github-actions

Copy link
Copy Markdown
Contributor

This PR has been automatically marked as stale because it has not had recent activity from the author. It will be closed if no further activity occurs. If the PR was closed and you want it re-opened, let us know and we'll re-open the PR so that you can continue the contribution!

@github-actions github-actions Bot added the stale label Mar 10, 2026
@github-actions github-actions Bot closed this Mar 24, 2026
@awanlin awanlin reopened this Apr 7, 2026
@awanlin

awanlin commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

Hi @Shubhammete, this closed due to stale and I've reopened it, will you be able to follow up?

@github-actions github-actions Bot removed the stale label Apr 7, 2026
@Shubhammete

Copy link
Copy Markdown
Contributor Author

HI @awanlin,
Sorry for delay I was occupied with some work will try to finish it ASAP!!

@github-actions

github-actions Bot commented May 8, 2026

Copy link
Copy Markdown
Contributor

This PR has been automatically marked as stale because it has not had recent activity from the author. It will be closed if no further activity occurs. If the PR was closed and you want it re-opened, let us know and we'll re-open the PR so that you can continue the contribution!

@github-actions github-actions Bot added the stale label May 8, 2026
@Shubhammete

Copy link
Copy Markdown
Contributor Author

Hi @mbruhin
I need some time as my old instance is not available to use and new one has changes regarding plugin architecture they seperated create plugin into backend and frontend
I will setup new instance and will make and test the changes

@github-actions github-actions Bot removed the stale label May 13, 2026
Copilot AI review requested due to automatic review settings May 16, 2026 20:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds initial Bitbucket Cloud support to the Bitbucket Pull Requests plugin while preserving the existing Bitbucket Server/Data Center path.

Changes:

  • Adds Cloud/server config detection and separate Cloud fetch/mapping logic.
  • Adds Cloud annotation handling and response stubs.
  • Updates documentation and release metadata for Cloud support.

Reviewed changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
src/utils/isBitbucketSlugSet.ts Adds separate Server and Cloud annotation constants.
src/responseStubs.ts Adds Cloud entity and pull request response stubs.
src/components/Router.tsx Uses the shared slug helper for plugin availability.
src/components/HomePage/HomePagePullRequestsTable.test.tsx Updates test mapper usage after mapper rename.
src/api/BitbucketApi.ts Adds Cloud/server routing, Cloud fetch methods, and Cloud response mapping.
README.md Documents Cloud configuration and annotations.
config.d.ts Adds bitbucket.type frontend config schema.
.changeset/tiny-files-fix.md Adds release note for Cloud support.
Comments suppressed due to low confidence (1)

workspaces/bitbucket-pull-requests/plugins/bitbucket-pull-requests/README.md:56

  • The newly documented Cloud mode still uses the proxy block above with target: https://bitbucket.org, but Bitbucket Cloud REST API calls in this PR are under the https://api.bitbucket.org/2.0 host. Users copying this configuration for Cloud will proxy requests to the wrong host.
  # Defaults to server, set type for cloud hosted bitbucket
  type: cloud or server

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…endpoints and added tests

Signed-off-by: Shubham Mete <[email protected]>
@Shubhammete

Copy link
Copy Markdown
Contributor Author

Hi @mbruhin
sorry for the delay in getting back to this! I have addressed all the review comments
Let me know if anything else needs changing!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 9 changed files in this pull request and generated 5 comments.

Comments suppressed due to low confidence (3)

workspaces/bitbucket-pull-requests/plugins/bitbucket-pull-requests/src/api/BitbucketApi.ts:401

  • fetchPullRequestListForRepo forwards the UI state directly as state query param. The UI uses ALL by default, but Bitbucket Cloud does not support state=ALL, so the default view will 400/return nothing for cloud instances. Translate ALL to either (a) omit the state param or (b) expand to multiple state params (OPEN/MERGED/DECLINED/SUPERSEDED) before calling the Cloud endpoint.
    const params = new URLSearchParams();
    if (state) {
      // Cloud uses different state values: OPEN, MERGED, DECLINED, SUPERSEDED
      params.append('state', state);
    }
    params.append('pagelen', limit.toString());

workspaces/bitbucket-pull-requests/plugins/bitbucket-pull-requests/src/api/BitbucketApi.ts:407

  • Bitbucket Cloud pagelen has an upper bound (commonly 100). Setting pagelen to an arbitrary limit can cause request failures if callers pass a larger limit. Consider clamping limit to the Cloud maximum (and/or using paging) before setting pagelen.
    const params = new URLSearchParams();
    if (state) {
      // Cloud uses different state values: OPEN, MERGED, DECLINED, SUPERSEDED
      params.append('state', state);
    }
    params.append('pagelen', limit.toString());

    const response = await this.fetchApi.fetch(`${url}?${params}`, {
      headers: {
        'Content-Type': 'application/json',
      },
    });
    if (!response.ok) {

workspaces/bitbucket-pull-requests/plugins/bitbucket-pull-requests/README.md:57

  • Cloud homepage/user PR fetching requires configured workspaces (bitbucket.cloudWorkspaces), but the configuration section only documents proxyPath and type. Add documentation for bitbucket.cloudWorkspaces (and what it should contain) so Cloud users can successfully use the homepage card/user PR features.
bitbucket:
  # Defaults to /bitbucket/api and can be omitted if proxy is configured for that url
  proxyPath: /bitbucket/api
  # Defaults to server, set type for cloud hosted bitbucket
  type: cloud or server
</details>

Comment on lines +323 to +348
const proxyUrl = await this.getProxyUrl();
const repos: string[] = [];
let nextUrl:
| string
| undefined = `${proxyUrl}${this.proxyPath}/2.0/repositories/${workspace}?pagelen=100`;

while (nextUrl) {
const response: Response = await this.fetchApi.fetch(nextUrl, {
headers: {
'Content-Type': 'application/json',
},
});

if (!response.ok) {
throw new Error(
`Failed to fetch repositories for workspace '${workspace}'`,
);
}

const data: any = await response.json();
const pageRepos = (data.values || [])
.map((repo: any) => repo.slug)
.filter((slug: any) => typeof slug === 'string');
repos.push(...pageRepos);
nextUrl = data.next;
}
Comment on lines +436 to +461

const allPullRequests: PullRequest[] = [];
for (const workspace of this.cloudWorkspaces) {
const repos = await this.fetchWorkspaceRepositories(workspace);
for (const repo of repos) {
const repoPullRequests = await this.fetchRepoPullRequests(
workspace,
repo,
states,
Math.min(limit, DEFAULT_LIMIT),
);
allPullRequests.push(...repoPullRequests);
}
}

let pullRequests = allPullRequests;

// Cloud API returns all PRs for the user, so we filter by role client-side.
if (role === 'AUTHOR') {
pullRequests = pullRequests.filter(pr => pr.author.slug === name);
} else if (role === 'REVIEWER') {
pullRequests = pullRequests.filter(pr =>
pr.reviewers.some(reviewer => reviewer.slug === name),
);
}

Comment on lines +55 to +56
# Defaults to server, set type for cloud hosted bitbucket
type: cloud or server
annotations:
bitbucket.com/project-slug: <example-bitbucket-project-name>/<example-bitbucket-repo-name>
# For Bitbucket cloud use
bitbucket.org/repo-slug: my-workspace/my-repo
Comment on lines 181 to 247
@@ -173,52 +203,45 @@ describe('PullRequestList', () => {
</TestApiProvider>,
);

// Wait for initial load and confirm default state is ALL
// Verify table still renders with no data
await waitFor(() => {
expect(screen.getByText('Bitbucket Pull Requests')).toBeInTheDocument();
expect(lastStateParam).toBe('ALL');
});

// Click on the Merged filter button and ensure subsequent call uses MERGED
const mergedButton = screen.getByRole('button', { name: /Merged/i });
await userEvent.click(mergedButton);

await waitFor(() => {
expect(lastStateParam).toBe('MERGED');
// No data text should be visible (or similar empty state indicator)
// This depends on what the component shows when there's no data
expect(screen.queryByText(/^#\d+$/)).not.toBeInTheDocument();
});
});

it('should handle empty PR list', async () => {
// Mock empty response
const emptyResponseStub = {
size: 0,
limit: 25,
isLastPage: true,
values: [],
start: 0,
};

it('should display cloud pull requests for cloud-annotated entities', async () => {
worker.use(
rest.get(
'http://exampleapi.com/bitbucket/api/projects/testproject/repos/testrepo/pull-requests',
(_, res, ctx) => res(ctx.json(emptyResponseStub)),
'http://exampleapi.com/bitbucket/api/2.0/repositories/myworkspace/example-project/pullrequests',
(_, res, ctx) => res(ctx.json(pullRequestsCloudResponseStub)),
),
);

render(
<TestApiProvider apis={apis}>
<EntityProvider entity={entityStub}>
<TestApiProvider apis={cloudApis}>
<EntityProvider entity={entityCloudStub}>
<PullRequestList />
</EntityProvider>
</TestApiProvider>,
);

// Verify table still renders with no data
await waitFor(() => {
expect(screen.getByText('Bitbucket Pull Requests')).toBeInTheDocument();
// No data text should be visible (or similar empty state indicator)
// This depends on what the component shows when there's no data
expect(screen.queryByText(/^#\d+$/)).not.toBeInTheDocument();
});

await waitFor(() => {
pullRequestsCloudResponseStub.values.forEach(pr => {
expect(screen.getByText(pr.title)).toBeInTheDocument();
});
});

expect(
screen.getByText(
pullRequestsCloudResponseStub.values[0].author.display_name,
),
).toBeInTheDocument();
});
});
@Shubhammete

Copy link
Copy Markdown
Contributor Author

Hi @awanlin @mbruhin @Parsifal-M
I validated the Bitbucket integration using a cloud instance. Due to org restrictions, I’m not able to share direct access, but attaching a screenshot for reference.

Screenshot 2026-05-23 at 7 14 05 PM

The setup is working as expected with the following configuration:
catalog.yaml

apiVersion: backstage.io/v1alpha1
kind: Component
metadata:
  name: bitbucket
  annotations:
    # Format: workspace/repo for Cloud, PROJECT/repo for Server
    bitbucket.org/repo-slug: demo-project/demo-repo
spec:
  type: website
  lifecycle: experimental
  owner: guests
  system: examples

app-config.yaml

....
  type: cloud
  proxyPath: /bitbucket/api
  
  proxy:
  '/bitbucket/api':
    target: https://api.bitbucket.org
    changeOrigin: true
    headers:
      Authorization: Basic ${BITBUCKET_TOKEN}
      Accept: 'application/json'
      Content-Type: 'application/json'
 ....

Please let me know if this aligns with the expected approach or if I should explore any additional scenarios.

@github-actions

Copy link
Copy Markdown
Contributor

This PR has been automatically marked as stale because it has not had recent activity from the author. It will be closed if no further activity occurs. If the PR was closed and you want it re-opened, let us know and we'll re-open the PR so that you can continue the contribution!

@github-actions github-actions Bot added the stale label Jun 22, 2026
@Shubhammete

Copy link
Copy Markdown
Contributor Author

Hi @awanlin @mbruhin @smymoon @Parsifal-M
Any updates anything more required from my side?

@github-actions github-actions Bot removed the stale label Jul 7, 2026

@awanlin awanlin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Shubhammete, there's a few outstanding comments that need to be addressed:

  1. Pagination bypasses proxy — data.next returns absolute Bitbucket URLs that skip the Backstage proxy, breaking auth/CORS
  2. Sequential repo enumeration is slow — Cloud user PRs iterate every repo in every workspace sequentially; will hit rate limits on large workspaces
  3. Invalid YAML example — type: cloud or server is a literal string, not a valid config value
  4. Annotation key mismatch — README says bitbucket.org/repo-slug, code uses bitbucket.com/repo-slug
  5. Missing state filter test — The test verifying state query params was removed and not replaced

I've also added two of my own. 👍

options.configApi?.getOptionalString('bitbucket.proxyPath') ||
DEFAULT_PROXY_PATH;
const cloudWorkspaces =
options.configApi?.getOptionalStringArray('bitbucket.cloudWorkspaces') ||

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This - bitbucket.cloudWorkspaces - isn't in the config.d.ts or the README.


public mapServerPullRequests(data: any): PullRequest[] {
return mapServerPullRequests(data);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems a little odd, why is this here?

@Shubhammete

Copy link
Copy Markdown
Contributor Author

Thanks @awanlin for the review. I will review all the comments and resolve them!

@Shubhammete Shubhammete closed this by deleting the head repository Aug 9, 2026
@Shubhammete

Copy link
Copy Markdown
Contributor Author

Hi @awanlin, @mbruhin, @Parsifal-M, @smymoon
I accidentally deleted the head repository. I've resolved all the comments and opened a new PR: #10278

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🚀 Bitbucket-Pull-Requests: Add Bitbucket Cloud support

5 participants