Skip to content

Mirror pipeline notifications

Craig Furman requested to merge craigf/mirror-pipeline-notifications into master

When run in a CI job on a repository mirror, it will search the mirror source for merge requests corresponding to the job commit, or in the case of master, corresponding to the job commit or any parent of the job commit (1 level deep).

Very similar to https://gitlab.com/gitlab-com/gl-infra/k8s-workloads/common/blob/master/bin/notify-mr.


You can see an example set of notifications using a woodhouse image built from this branch, and my API token, here: cross-project-pipelines/test-project!3 (merged). The 2nd message is from the master pipeline, post-merge.

You can see an example configuration stanza here: https://gitlab.com/cross-project-pipelines/test-project/-/blob/master/.gitlab-ci.yml

More generally:

notify_mirror_source:
  stage: notify
  image: registry.gitlab.com/gitlab-com/gl-infra/woodhouse:latest
  script: woodhouse gitlab notify-mirrored-mr
  rules:
    - if: '$EXAMPLE_IS_MIRROR == "1"'

That simple CI job config, with the woodhouse image and that command, will work on any of our repositories with only GITLAB_API_TOKEN set in the mirror's CI vars, with the ops-gitlab-net's .com token, so that it can write comments. If for whatever reason the mirror is on a gitlab instance other than gitlab.com, and/or the mirror's project path differs from the source, these options can both be overridden, but our workflow does not currently require that.


@gitlab-com/gl-infra/sre-observability we either need "push" pipeline linking (something like this) or pull (something like gitlab-com/gl-infra/k8s-workloads/gitlab-helmfiles!202 (closed)), for tanka + woodhouse. There are trade-offs with both approaches. One advantage of the push approach in this MR is that it would not require creating a new user with differntly-scoped permissions (see helmfiles MR thread above).

@jarv as the autor of the shell script above, and someone who participated in the discussion in gitlab-com/gl-infra/k8s-workloads/gitlab-helmfiles!202 (closed), wdyt of this?

Edited by Craig Furman

Merge request reports