notification-controller icon indicating copy to clipboard operation
notification-controller copied to clipboard

feat: workflow_dispatch approach for GitLab

Open mavogel opened this issue 2 years ago • 3 comments

I was wondering if there is something planned to add the workflow_dispatch approach for GitLab, as it is with GitHub

-> https://github.com/fluxcd/notification-controller/blob/5500739269e6772343710405dbac9dc893e11c05/internal/notifier/github_dispatch.go#L110

During my research I found this issue: https://forum.gitlab.com/t/workflow-dispatch-approach-in-gitlab-ci/72426, which states triggering a pipeline with passed in environment variables (aka payload)

Update: or will the forwarder with a POST to trigger a pipeline / job via webhook do it: https://github.com/fluxcd/notification-controller/blob/5500739269e6772343710405dbac9dc893e11c05/internal/notifier/forwarder.go#L80 ?

Or does anyone have experience in implementing it? :)

mavogel avatar Dec 05 '23 14:12 mavogel

I am also trying to close the Feedback Loop from Flux to GitLab. Unfortunately, GitLab doesn't provide any action on a commit status change 😔.

Another option would be to use a Post-Deployment Job that triggers the GitLab Pipeline. But I think it would be nice to have this feature built into flux since I imagine it is a common use case.

To use the forwarder, a proxy would be required to translate the event from the flux provider to a valid GitLab webhook request.

Couldn't we create a GitLab Pipeline Trigger Provider that does this? I have something like this in mind.

---
apiVersion: notification.toolkit.fluxcd.io/v1beta3
kind: Provider
metadata:
  name: gitlab-trigger
spec:
  type: gitlabtrigger
  address: # https://gitlab.example.com/api/v4/projects/<project_id>/ref/<ref_name>/trigger/pipeline
  secretRef:
    name: #<token> with your pipeline trigger token.
---
apiVersion: notification.toolkit.fluxcd.io/v1beta3
kind: Alert
metadata:
  name: gitlab-trigger
spec:
  summary: "staging (us-west-2)"
  providerRef:
    name: gitlab-trigger
  eventSeverity: info
  eventSources:
    - kind: Kustomization
      name: 'podinfo'
  eventMetadata: # could be used for optional CI/CD variables to be passed to the pipeline.
    - key: 'cluster'
      value: 'staging'
    - key: 'region'
      value: 'us-west-2'

I am happy to provide a PR if we agree that this makes sense.

mo-rieger avatar Apr 11 '24 15:04 mo-rieger

We need for GitLab to tell us if the Pipeline Trigger is the right approach. CC @nagyv

stefanprodan avatar Apr 11 '24 15:04 stefanprodan

Hi! GitLab PM here. One GitLab team is working on https://gitlab.com/groups/gitlab-org/-/epics/10866 with the specific intent of supporting Flux integrations. Please, add you voice to the linked epic!

nagyv avatar Apr 15 '24 13:04 nagyv