Skip to content
Open
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
17 changes: 17 additions & 0 deletions pkg/controller/pipelines.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,23 @@ func (c *Controller) PullRefMetrics(ctx context.Context, ref schemas.Ref) error
return fmt.Errorf("error fetching project pipelines for %s: %v", ref.Project.Name, err)
}

// when "Enable merged results pipelines" is enabled (or other cases), the refName needs to end by /merge instead of /head
if len(pipelines) == 0 && ref.Kind == schemas.RefKindMergeRequest {
refName = fmt.Sprintf("refs/merge-requests/%s/merge", ref.Name)
pipelines, _, err = c.Gitlab.GetProjectPipelines(ctx, ref.Project.Name, &goGitlab.ListProjectPipelinesOptions{
// We only need the most recent pipeline
ListOptions: goGitlab.ListOptions{
PerPage: 1,
Page: 1,
},
Ref: &refName,
})

if err != nil {
return fmt.Errorf("error fetching project pipelines for %s: %v", ref.Project.Name, err)
}
}

if len(pipelines) == 0 {
log.WithFields(logFields).Debug("could not find any pipeline for the ref")

Expand Down