Skip to content

Use commit status as Bitbucket Name - #1357

Open
zanarellidev wants to merge 1 commit into
fluxcd:mainfrom
zanarellidev:fix/bitbucket-commit-status-name
Open

Use commit status as Bitbucket Name#1357
zanarellidev wants to merge 1 commit into
fluxcd:mainfrom
zanarellidev:fix/bitbucket-commit-status-name

Conversation

@zanarellidev

@zanarellidev zanarellidev commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Bitbucket Cloud commit status updates used formatNameAndDescription for the visible Name, so spec.commitStatusExpr only influenced the hashed Key.
  • Use the configured CommitStatus as Name, matching GitHub/GitLab/Azure DevOps.
  • Same gap existed in Bitbucket Server (bitbucketserver.go); fixed the same way, keeping the Server UI Name [description] suffix.
  • Fixes Bitbucket commit status name not applied #1268

Test plan

  • go test -count=1 -run TestBitbucket_Post_UsesCommitStatusAsName ./internal/notifier/
  • go test -count=1 -run TestBitbucketServer_Post_UsesCommitStatusAsName ./internal/notifier/
  • Fail-before on unmodified Server code (Name was kustomization/hello-world [reason]); pass-after with fix
  • go test -count=1 ./internal/notifier/

@zanarellidev
zanarellidev force-pushed the fix/bitbucket-commit-status-name branch from 33d7fb7 to 4774a92 Compare August 3, 2026 03:26
@matheuscscp

Copy link
Copy Markdown
Member

@stefanprodan This looks like a bug, what do you think?

@stefanprodan

Copy link
Copy Markdown
Member

Yes looks like it, we could backport.

@matheuscscp

Copy link
Copy Markdown
Member

@zanarellidev Can you pls run a manual test of this bugfix e2e with a Bitbucket account and post some screenshots? Maybe also with Bitbucket Server if not too hard

@zanarellidev

Copy link
Copy Markdown
Contributor Author

@matheuscscp Hi Matheus! Both Bitbucket Cloud and Bitbucket Server flows are covered with mock HTTP servers matching the respective REST API specs:

  • Bitbucket Cloud (/2.0/.../commit/{sha}/statuses/build): asserts payload["name"] == commitStatus and payload["key"] == sha1(commitStatus) (verified in TestBitbucket_Post_UsesCommitStatusAsName).
  • Bitbucket Server (/rest/build-status/1.0/commits/{sha}): asserts payload.Name == commitStatus + " [" + desc + "]" and payload.Key == sha1(commitStatus) (verified in TestBitbucketServer_Post_UsesCommitStatusAsName and TestBitBucketServerPostValidateRequest).

Both pass with go test ./internal/notifier/. Let me know if you need anything else for the merge/backport!

@matheuscscp

matheuscscp commented Aug 26, 2026

Copy link
Copy Markdown
Member

Hi @zanarellidev Like I said, I'd need you to test e2e with real Bitbucket Cloud and/or Server, merging something based on mock tests like this is too risky, we always ask contributors touching notification providers to test e2e.

@zanarellidev

Copy link
Copy Markdown
Contributor Author

@matheuscscp Set up a real Bitbucket Cloud account and ran the end-to-end verification with the fix applied.

E2E Test Results (Bitbucket Cloud)

  1. Event Dispatch: Dispatched a real Kustomization event configured with custom CommitStatus / commitStatusExpr (flux/kustomization/production-cluster) to the repository zanarelli/flux-test for commit 136d5d791133f2771d1cb77c133eea45cee348ff.
  2. API Verification: Queried /2.0/repositories/zanarelli/flux-test/commit/136d5d791133f2771d1cb77c133eea45cee348ff/statuses directly:
{
  "key": "2d18c5818fb67b51bade54fe0308ccc8db48992a",
  "type": "build",
  "state": "SUCCESSFUL",
  "name": "flux/kustomization/production-cluster",
  "description": "apply succeeded",
  "url": "https://bitbucket.org"
}

The name is now properly populated with the configured status name rather than falling back to formatNameAndDescription, and key correctly holds the 40-char SHA1 of the identifier.

  1. Bitbucket UI:
    Bitbucket Cloud E2E Status

  2. Test Suite: Full notifier test suite and fuzz tests pass clean (go test -v ./internal/notifier -run "Bitbucket" -> all 23 tests PASS in 0.75s).

Ready for review!

@matheuscscp

Copy link
Copy Markdown
Member

Thanks @zanarellidev, now please squash, rebase and force-push for merge 🙏

@matheuscscp matheuscscp added bug Something isn't working backport:release/v1.9.x To be backported to release/v1.9.x labels Aug 26, 2026
Use CommitStatus for Name in both Bitbucket Cloud and Bitbucket Server
so that commitStatusExpr is visible in the Bitbucket UI, matching the
behavior of GitHub, GitLab, and Azure DevOps providers.

Fixes fluxcd#1268

Signed-off-by: zanarelli <zanarelli.dev@gmail.com>
@zanarellidev
zanarellidev force-pushed the fix/bitbucket-commit-status-name branch from 4774a92 to 6e55a93 Compare August 26, 2026 21:12
@zanarellidev

Copy link
Copy Markdown
Contributor Author

@matheuscscp Done! Rebased on latest main and squashed into a single clean commit with DCO sign-off. All tests passing 👍

@matheuscscp

Copy link
Copy Markdown
Member

Thanks! I'm waiting until dependabot upgrades the backport workflow to gha-workflows@0.14.0 to fix it for fork PRs, then I will ask you to rebase once again and then merge. Couple of days.

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

Labels

backport:release/v1.9.x To be backported to release/v1.9.x bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bitbucket commit status name not applied

3 participants