2

Requirement - In my self hosted gitlab instance there are multiple projects maintained by different users which are all using one particular tag of an image from the container registry of my project. That tag is now outdated and I have created a new tag for the image and I would like to notify all the users to use the new tag

Is there any webhook available in gitlab which can be enabled for all PULL request of image:tag to send notifications (email,slack) to the authors of ci/cd pipelines?

Or maybe configure the pipeline to detect the image and tag being used and if it is the one in question then send notifications?

P.S. - Gitlab instance is using docker container registry

ashishpm
  • 408
  • 1
  • 6
  • 19

2 Answers2

2

An approach that involves custom scripting. Less elegant than VonC's suggestion ;-)

… detect the image and tag being used and if it is the one in question then send notifications?

  1. You could try tailing the logs while pulling the old tag manually.
  2. Searching for the image & tag name in your log slice should help determine how the usernames of associated events can be parsed out. Probably with jq.
  3. A custom script could then be added to regularly repeat that parsing and for example send an email to users who trigger those events.
Katrin Leinweber
  • 1,316
  • 13
  • 33
1

"Webhook" ("custom HTTP callbacks") means a local listener to GitLab events.

Considering you are managing your GitLab instance, a better option would be to create a pipeline for external pull requests (since GitLab 12.3, Aug. 2019)

on-pull-requests:
  script: echo 'this should run on pull requests'
  only:
    - external_pull_requests

This pipeline can check if a Dockerfile is being merged, and if that Dockerfile uses the wrong tag.
If it does, it can deny said pull request.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Hi @vonc , my gitlab instance allows external users to kick off ci/cd pipelines for any project using gitlab apis. In that case there wont be any change to the codebase of the project. A new pipeline will be created using the image mentioned in .gitlab-ci.yml file. How to handle this? – ashishpm Dec 09 '22 at 12:04
  • @ashishpm This is a pipeline which would only do domething on pull request, so the fact external users can "kick off ci/cd pipelines for any project using gitlab apis" won't change anything. – VonC Dec 09 '22 at 14:07
  • as I have mentioned in the question there are multiple repositories which are using my image. So I would have to manually connect to each one of them and configure the pipeline which would be laborious. Also running an additional pipeline for each pull request in every repository would be a waste of computing resources for a task which is not something of high priority – ashishpm Dec 15 '22 at 05:17
  • 1
    @ashishpm Then the custom script approach from Katrin might be a better fit. – VonC Dec 15 '22 at 06:46