Skip to content

Commit d4e2a92

Browse files
committed
enhance: add PipelineRun name in pr json marshalling
Signed-off-by: Zaki Shaikh <zashaikh@redhat.com>
1 parent 860c901 commit d4e2a92

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

pkg/pipelineascode/match.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,9 +396,14 @@ func filterRunningPipelineRunOnTargetTest(testPipeline string, prs []*tektonv1.P
396396
// - the template variable with the one from the event (this includes the remote pipeline that has template variables).
397397
func (p *PacRun) changePipelineRun(ctx context.Context, repo *v1alpha1.Repository, prs []*tektonv1.PipelineRun) error {
398398
for k, pr := range prs {
399+
prName := pr.GetName()
400+
if prName == "" {
401+
prName = pr.GetGenerateName()
402+
}
403+
399404
b, err := json.Marshal(pr)
400405
if err != nil {
401-
return err
406+
return fmt.Errorf("failed to marshal PipelineRun %s: %w", prName, err)
402407
}
403408

404409
name := secrets.GenerateBasicAuthSecretName()
@@ -410,7 +415,7 @@ func (p *PacRun) changePipelineRun(ctx context.Context, repo *v1alpha1.Repositor
410415
var np *tektonv1.PipelineRun
411416
err = json.Unmarshal([]byte(processed), &np)
412417
if err != nil {
413-
return err
418+
return fmt.Errorf("failed to unmarshal PipelineRun %s: %w", prName, err)
414419
}
415420
// don't crash when we don't have any annotations
416421
if np.Annotations == nil {

0 commit comments

Comments
 (0)