Skip to content

Commit

Permalink
webhooks: use the merge request IID as ref name
Browse files Browse the repository at this point in the history
  • Loading branch information
mvisonneau committed Jun 3, 2021
1 parent fe57b89 commit 436f91f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/controller/webhooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"regexp"
"strconv"
"strings"

"github.com/mvisonneau/gitlab-ci-pipelines-exporter/pkg/config"
Expand All @@ -14,11 +15,13 @@ import (

func (c *Controller) processPipelineEvent(e goGitlab.PipelineEvent) {
var refKind schemas.RefKind
refName := e.ObjectAttributes.Ref

// TODO: Perhaps it would be nice to match upon the regexp to validate
// that it is actually a merge request ref
if e.MergeRequest.IID != 0 {
refKind = schemas.RefKindMergeRequest
refName = strconv.Itoa(e.MergeRequest.IID)
} else if e.ObjectAttributes.Tag {
refKind = schemas.RefKindTag
} else {
Expand All @@ -28,7 +31,7 @@ func (c *Controller) processPipelineEvent(e goGitlab.PipelineEvent) {
c.triggerRefMetricsPull(schemas.NewRef(
schemas.NewProject(e.Project.PathWithNamespace),
refKind,
e.ObjectAttributes.Ref,
refName,
))
}

Expand Down

0 comments on commit 436f91f

Please sign in to comment.