Skip to content

Add Bitbucket Data Center pull request source support#261

Open
gjkim42 wants to merge 1 commit intomainfrom
axon-task-260
Open

Add Bitbucket Data Center pull request source support#261
gjkim42 wants to merge 1 commit intomainfrom
axon-task-260

Conversation

@gjkim42
Copy link
Collaborator

@gjkim42 gjkim42 commented Feb 11, 2026

Summary

  • Add BitbucketDataCenterPRs as a new source type for TaskSpawner, enabling teams using Bitbucket Data Center to leverage automated task spawning for PR review and processing
  • Implement BitbucketDataCenterSource using the Bitbucket DC REST API (/rest/api/1.0) with pagination support and Bearer token authentication
  • Parse Bitbucket DC repository URLs in all common formats: SCM clone URLs (/scm/PROJECT/repo), browse URLs (/projects/PROJECT/repos/repo), and SSH URLs

Test plan

  • Unit tests for BitbucketDataCenterSource (discovery, pagination, state filtering, auth, comments, error handling)
  • Unit tests for parseBitbucketDCRepo (all URL formats)
  • Unit tests for deployment builder with Bitbucket DC
  • Unit tests for buildSource with Bitbucket DC PRs
  • Integration tests for TaskSpawner with Bitbucket DC source (with and without secretRef)
  • make verify passes
  • make test passes
  • make test-integration passes (39/39 specs)

Fixes #260

🤖 Generated with Claude Code


Summary by cubic

Adds Bitbucket Data Center pull request source to TaskSpawner so teams can auto-spawn tasks for PR review on Bitbucket DC. Addresses task #260 with REST API integration, URL parsing, CRD updates, and CLI wiring.

  • New Features

    • New source: bitbucketDataCenterPRs with state filter (OPEN, MERGED, DECLINED, ALL)
    • BitbucketDataCenterSource uses /rest/api/1.0 with pagination and Bearer auth
    • Repo URL parsing for SCM, projects/browse, and SSH formats
    • Deployment builder passes base URL, project, repo; injects BITBUCKET_TOKEN from workspace.secretRef
    • CLI printer displays “Bitbucket DC PRs” and state
    • Example manifests added under examples/05-taskspawner-bitbucket-dc-prs
  • Migration

    • taskTemplate.workspaceRef is required when using bitbucketDataCenterPRs (CRD validation)
    • Provide BITBUCKET_TOKEN via Workspace secretRef for authenticated API access
    • Set Workspace repo to a supported Bitbucket DC URL format (SCM, projects, SSH)

Written for commit b8560f0. Summary will update on new commits.

Add a new BitbucketDataCenterPRs source type to TaskSpawner that
discovers pull requests from Bitbucket Data Center repositories. This
allows teams using Bitbucket DC to leverage automated task spawning
for PR review and processing.

Changes:
- Add BitbucketDataCenterPRs API type with state filter (OPEN, MERGED,
  DECLINED, ALL)
- Implement BitbucketDataCenterSource using the Bitbucket DC REST API
  (/rest/api/1.0) with pagination and Bearer token authentication
- Parse Bitbucket DC repository URLs (SCM clone, browse, SSH formats)
- Wire up deployment builder, spawner, and CLI printer for the new
  source
- Add unit tests, integration tests, and example manifests

Fixes #260

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

2 issues found across 18 files

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="test/integration/taskspawner_test.go">

<violation number="1" location="test/integration/taskspawner_test.go:709">
P2: Missing `HaveLen(1)` assertion on `Containers` before indexing `[0]`. The first Bitbucket DC test correctly guards with `Expect(createdDeploy.Spec.Template.Spec.Containers).To(HaveLen(1))` before accessing `Containers[0]`, but this test does not, which is inconsistent and would produce a confusing panic instead of a clear test failure if the container list were empty.</violation>
</file>

<file name="internal/source/bitbucket_dc.go">

<violation number="1" location="internal/source/bitbucket_dc.go:173">
P2: Missing pagination for PR activities/comments — only the first page (100 activities) is fetched, while `fetchAllPRs` properly paginates. Since the activities endpoint returns all activity types (APPROVED, RESCOPED, etc.) and only COMMENTED entries are kept, active PRs could lose most of their comments. Consider adding a pagination loop similar to `fetchAllPRs`, or at minimum paginating until `maxCommentBytes` is reached.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.


By("Verifying the Deployment spec has Bitbucket DC args")
Expect(createdDeploy.Spec.Template.Spec.Containers).To(HaveLen(1))
container := createdDeploy.Spec.Template.Spec.Containers[0]
Copy link

@cubic-dev-ai cubic-dev-ai bot Feb 11, 2026

Choose a reason for hiding this comment

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

P2: Missing HaveLen(1) assertion on Containers before indexing [0]. The first Bitbucket DC test correctly guards with Expect(createdDeploy.Spec.Template.Spec.Containers).To(HaveLen(1)) before accessing Containers[0], but this test does not, which is inconsistent and would produce a confusing panic instead of a clear test failure if the container list were empty.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At test/integration/taskspawner_test.go, line 709:

<comment>Missing `HaveLen(1)` assertion on `Containers` before indexing `[0]`. The first Bitbucket DC test correctly guards with `Expect(createdDeploy.Spec.Template.Spec.Containers).To(HaveLen(1))` before accessing `Containers[0]`, but this test does not, which is inconsistent and would produce a confusing panic instead of a clear test failure if the container list were empty.</comment>

<file context>
@@ -626,6 +626,196 @@ var _ = Describe("TaskSpawner Controller", func() {
+
+			By("Verifying the Deployment spec has Bitbucket DC args")
+			Expect(createdDeploy.Spec.Template.Spec.Containers).To(HaveLen(1))
+			container := createdDeploy.Spec.Template.Spec.Containers[0]
+			Expect(container.Name).To(Equal("spawner"))
+			Expect(container.Image).To(Equal(controller.DefaultSpawnerImage))
</file context>
Suggested change
container := createdDeploy.Spec.Template.Spec.Containers[0]
Expect(createdDeploy.Spec.Template.Spec.Containers).To(HaveLen(1))
container := createdDeploy.Spec.Template.Spec.Containers[0]
Fix with Cubic

return prs, page.NextPageStart, page.IsLastPage, nil
}

func (s *BitbucketDataCenterSource) fetchPRComments(ctx context.Context, prID int) (string, error) {
Copy link

@cubic-dev-ai cubic-dev-ai bot Feb 11, 2026

Choose a reason for hiding this comment

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

P2: Missing pagination for PR activities/comments — only the first page (100 activities) is fetched, while fetchAllPRs properly paginates. Since the activities endpoint returns all activity types (APPROVED, RESCOPED, etc.) and only COMMENTED entries are kept, active PRs could lose most of their comments. Consider adding a pagination loop similar to fetchAllPRs, or at minimum paginating until maxCommentBytes is reached.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At internal/source/bitbucket_dc.go, line 173:

<comment>Missing pagination for PR activities/comments — only the first page (100 activities) is fetched, while `fetchAllPRs` properly paginates. Since the activities endpoint returns all activity types (APPROVED, RESCOPED, etc.) and only COMMENTED entries are kept, active PRs could lose most of their comments. Consider adding a pagination loop similar to `fetchAllPRs`, or at minimum paginating until `maxCommentBytes` is reached.</comment>

<file context>
@@ -0,0 +1,225 @@
+	return prs, page.NextPageStart, page.IsLastPage, nil
+}
+
+func (s *BitbucketDataCenterSource) fetchPRComments(ctx context.Context, prID int) (string, error) {
+	u := fmt.Sprintf("%s/rest/api/1.0/projects/%s/repos/%s/pull-requests/%d/activities",
+		s.BaseURL, s.Project, s.Repo, prID)
</file context>
Fix with Cubic

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.

support bitbucket datacenter support

1 participant