Skip to content

Commit 4f216be

Browse files
committed
fix(bitbucket-cloud): assign unique statue name in Bitbucket Cloud
Update Bitbucket Cloud provider to use GetCheckName helper for commit status key. This enables unique status reporting per PipelineRun by using the format "ApplicationName / PipelineRunName" instead of just the application name. Changes: - Replace hardcoded ApplicationName with GetCheckName in CreateStatus - Update tests to include OriginalPipelineRunName in StatusOpts - Add assertion in MuxCreateCommitstatus to verify correct key format Fixes: #2237 JIRA: https://issues.redhat.com/browse/SRVKP-9636 Signed-off-by: Zaki Shaikh <[email protected]>
1 parent 9572f3b commit 4f216be

File tree

3 files changed

+24
-12
lines changed

3 files changed

+24
-12
lines changed

pkg/provider/bitbucketcloud/bitbucket.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ func (v *Provider) CreateStatus(_ context.Context, event *info.Event, statusopts
109109
}
110110

111111
cso := &bitbucket.CommitStatusOptions{
112-
Key: v.pacInfo.ApplicationName,
112+
Key: provider.GetCheckName(statusopts, v.pacInfo),
113113
Url: detailsURL,
114114
State: statusopts.Conclusion,
115115
Description: statusopts.Title,

pkg/provider/bitbucketcloud/bitbucket_test.go

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ func TestGetCommitInfo(t *testing.T) {
273273
}
274274

275275
func TestCreateStatus(t *testing.T) {
276+
originalPipelineRunName := "hello-af9ch"
276277
tests := []struct {
277278
name string
278279
wantErr bool
@@ -283,60 +284,68 @@ func TestCreateStatus(t *testing.T) {
283284
{
284285
name: "skipped",
285286
status: provider.StatusOpts{
286-
Conclusion: "skipped",
287+
Conclusion: "skipped",
288+
OriginalPipelineRunName: originalPipelineRunName,
287289
},
288290
expectedDescSubstr: "Skipping",
289291
},
290292
{
291293
name: "neutral",
292294
status: provider.StatusOpts{
293-
Conclusion: "neutral",
295+
Conclusion: "neutral",
296+
OriginalPipelineRunName: originalPipelineRunName,
294297
},
295298
expectedDescSubstr: "stopped",
296299
},
297300
{
298301
name: "completed with comment",
299302
status: provider.StatusOpts{
300-
Conclusion: "success",
301-
Status: "completed",
302-
Text: "Happy as a bunny",
303+
Conclusion: "success",
304+
Status: "completed",
305+
OriginalPipelineRunName: originalPipelineRunName,
306+
Text: "Happy as a bunny",
303307
},
304308
expectedDescSubstr: "validated",
305309
expectedCommentSubstr: "Happy as a bunny",
306310
},
307311
{
308312
name: "failed",
309313
status: provider.StatusOpts{
310-
Conclusion: "failure",
314+
Conclusion: "failure",
315+
OriginalPipelineRunName: originalPipelineRunName,
311316
},
312317
expectedDescSubstr: "Failed",
313318
},
314319
{
315320
name: "details url",
316321
status: provider.StatusOpts{
317-
Conclusion: "failure",
318-
DetailsURL: "http://fail.com",
322+
Conclusion: "failure",
323+
DetailsURL: "http://fail.com",
324+
OriginalPipelineRunName: originalPipelineRunName,
319325
},
320326
expectedDescSubstr: "Failed",
321327
},
322328
{
323329
name: "pending",
324330
status: provider.StatusOpts{
325-
Conclusion: "pending",
331+
Conclusion: "pending",
332+
OriginalPipelineRunName: originalPipelineRunName,
326333
},
327334
expectedDescSubstr: "started",
328335
},
329336
{
330337
name: "success",
331338
status: provider.StatusOpts{
332-
Conclusion: "success",
339+
Conclusion: "success",
340+
OriginalPipelineRunName: originalPipelineRunName,
333341
},
334342
expectedDescSubstr: "validated",
335343
},
336344
{
337345
name: "completed",
338346
status: provider.StatusOpts{
339-
Conclusion: "completed",
347+
Conclusion: "completed",
348+
OriginalPipelineRunName: originalPipelineRunName,
340349
},
341350
expectedDescSubstr: "Completed",
342351
},

pkg/provider/bitbucketcloud/test/bbcloudtest.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313

1414
"github.com/ktrysmt/go-bitbucket"
1515
"github.com/openshift-pipelines/pipelines-as-code/pkg/params/info"
16+
"github.com/openshift-pipelines/pipelines-as-code/pkg/params/settings"
1617
"github.com/openshift-pipelines/pipelines-as-code/pkg/provider"
1718
"github.com/openshift-pipelines/pipelines-as-code/pkg/provider/bitbucketcloud/types"
1819
"gotest.tools/v3/assert"
@@ -153,6 +154,8 @@ func MuxCreateCommitstatus(t *testing.T, mux *http.ServeMux, event *info.Event,
153154
bit, _ := io.ReadAll(r.Body)
154155
err := json.Unmarshal(bit, cso)
155156
assert.NilError(t, err)
157+
pacOpts := &info.PacOpts{Settings: settings.Settings{ApplicationName: settings.PACApplicationNameDefaultValue}}
158+
assert.Equal(t, provider.GetCheckName(expStatus, pacOpts), cso.Key)
156159

157160
if expStatus.DetailsURL != "" {
158161
assert.Equal(t, expStatus.DetailsURL, cso.Url)

0 commit comments

Comments
 (0)