Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Have getLatestPipelineID return branch pipeline ID if no merge request pipeline was found #36

Merged
merged 3 commits into from
Aug 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion pkg/vcs/gitlab/mr_status_updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,21 @@ func (p *RunStatusUpdater) getLatestPipelineID(ctx context.Context, rmd runstrea
return nil
}
log.Trace().Interface("pipelines", pipelines).Msg("retrieved pipelines for commit")
var pipelineID *int
if len(pipelines) > 0 {
for _, p := range pipelines {
if p.GetSource() == "merge_request_event" {
return gogitlab.Int(p.GetID())
pipelineID = gogitlab.Int(p.GetID())
return pipelineID
}
}
// Fallback behavior if Gitlab doesn't find any merge request pipelines
// Returns last pipeline ID in the pipelines list
if pipelineID == nil {
log.Debug().Msg("No merge request pipeline ID found for the commit. Using latest pipeline ID as fallback...")
pipelineID = gogitlab.Int(pipelines[len(pipelines)-1].GetID())
return pipelineID
}
}
return nil
}
Expand Down
Loading