Skip to content

Commit 6843d69

Browse files
committed
fix: correctly update pending and running commit status
Signed-off-by: ab-ghosh <[email protected]>
1 parent 565420c commit 6843d69

File tree

4 files changed

+31
-0
lines changed

4 files changed

+31
-0
lines changed

pkg/pipelineascode/pipelineascode.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,14 @@ func (p *PacRun) startPR(ctx context.Context, match matcher.Match) (*tektonv1.Pi
301301
return pr, fmt.Errorf("cannot use the API on the provider platform to create a in_progress status: %w", err)
302302
}
303303

304+
// Also update the parent status (without pipeline name) to reflect pipeline is now running.
305+
// This updates the initial "Pipelines as Code CI" status that was set when waiting for /ok-to-test.
306+
parentStatus := status
307+
parentStatus.OriginalPipelineRunName = ""
308+
if err := p.vcx.CreateStatus(ctx, p.event, parentStatus); err != nil {
309+
p.logger.Warnf("failed to update parent status: %v", err)
310+
}
311+
304312
// Patch pipelineRun with logURL annotation, skips for GitHub App as we patch logURL while patching CheckrunID
305313
if _, ok := pr.Annotations[keys.InstallationID]; !ok {
306314
patchAnnotations[keys.LogURL] = p.run.Clients.ConsoleUI().DetailURL(pr)

pkg/provider/gitlab/gitlab.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,11 @@ func (v *Provider) CreateStatus(_ context.Context, event *info.Event, statusOpts
281281
statusOpts.Conclusion = "success"
282282
statusOpts.Title = "completed"
283283
case "pending":
284+
statusOpts.Conclusion = "pending"
285+
}
286+
// When the pipeline is actually running (in_progress), show it as running
287+
// not pending. Pending is only for waiting states like /ok-to-test approval.
288+
if statusOpts.Status == "in_progress" {
284289
statusOpts.Conclusion = "running"
285290
}
286291
if statusOpts.DetailsURL != "" {

pkg/reconciler/reconciler.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,9 @@ func (r *Reconciler) updatePipelineRunToInProgress(ctx context.Context, logger *
360360
return nil
361361
}
362362

363+
// Also update the parent status (without pipeline name) to reflect pipeline is running.
364+
updateParentStatus(ctx, logger, detectedProvider, event, status)
365+
363366
logger.Info("updated in_progress status on provider platform for pipelineRun ", pr.GetName())
364367
return nil
365368
}

pkg/reconciler/status.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,10 @@ func (r *Reconciler) postFinalStatus(ctx context.Context, logger *zap.SugaredLog
158158

159159
err = createStatusWithRetry(ctx, logger, vcx, event, status)
160160
logger.Infof("pipelinerun %s has a status of '%s'", pr.Name, status.Conclusion)
161+
162+
// Also update the parent status (without pipeline name) to reflect pipeline completion.
163+
updateParentStatus(ctx, logger, vcx, event, status)
164+
161165
return pr, err
162166
}
163167

@@ -174,3 +178,14 @@ func createStatusWithRetry(ctx context.Context, logger *zap.SugaredLogger, vcx p
174178
}
175179
return fmt.Errorf("failed to report status: %w", finalError)
176180
}
181+
182+
// updateParentStatus updates the parent status (without pipeline name) to reflect the current state.
183+
// This ensures the initial "Pipelines as Code CI" status set when waiting for /ok-to-test is updated
184+
// when pipelines start or complete. Uses retry logic for resilience to transient network issues.
185+
func updateParentStatus(ctx context.Context, logger *zap.SugaredLogger, vcx provider.Interface, event *info.Event, status provider.StatusOpts) {
186+
parentStatus := status
187+
parentStatus.OriginalPipelineRunName = ""
188+
if err := createStatusWithRetry(ctx, logger, vcx, event, parentStatus); err != nil {
189+
logger.Warnf("failed to update parent status: %v", err)
190+
}
191+
}

0 commit comments

Comments
 (0)