From 1772ba091fa57bbfb804e7626eb1241b35b26a66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Harri=20Er=C3=A4nen?= Date: Fri, 6 Mar 2026 16:43:58 +0200 Subject: [PATCH] fix(bbdc): resolve annotated tag object SHA to commit SHA before posting build status (#6203) Co-authored-by: Harri --- server/forge/bitbucketdatacenter/bitbucketdatacenter.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/server/forge/bitbucketdatacenter/bitbucketdatacenter.go b/server/forge/bitbucketdatacenter/bitbucketdatacenter.go index f182b3788..ea36e8b24 100644 --- a/server/forge/bitbucketdatacenter/bitbucketdatacenter.go +++ b/server/forge/bitbucketdatacenter/bitbucketdatacenter.go @@ -579,6 +579,14 @@ func (c *client) updatePipelineFromCommits(ctx context.Context, u *model.User, r if err != nil { return nil, fmt.Errorf("unable to read commit: %w", err) } + + // In Bitbucket Data Center, when using annotated tags, the webhook's ToHash is the tag object SHA, not the actual commit SHA. + // Update p.Commit so that build statuses are posted to the correct commit SHA. + if p.Event == model.EventTag && commit.ID != "" && commit.ID != p.Commit { + p.Commit = commit.ID + p.ForgeURL = fmt.Sprintf("%s/projects/%s/repos/%s/commits/%s", c.url, r.Owner, r.Name, commit.ID) + } + p.Message = commit.Message opts := &bb.CompareChangesOptions{}