github.com/argoproj/argo-events@v1.9.1/docs/eventsources/setup/gitlab.md (about)

     1  # GitLab
     2  
     3  GitLab event-source programmatically configures webhooks for projects on GitLab and helps sensor trigger the workloads upon events.
     4  
     5  ## Event Structure
     6  
     7  The structure of an event dispatched by the event-source over the eventbus looks like following,
     8  
     9              {
    10                  "context": {
    11                    "type": "type_of_event_source",
    12                    "specversion": "cloud_events_version",
    13                    "source": "name_of_the_event_source",
    14                    "id": "unique_event_id",
    15                    "time": "event_time",
    16                    "datacontenttype": "type_of_data",
    17                    "subject": "name_of_the_configuration_within_event_source"
    18                  },
    19                  "data": {
    20                     "body": "Body is the GitLab event data",
    21                     "headers": "Headers from the GitLab event",
    22                  }
    23              }
    24  
    25  ## Specification
    26  
    27  GitLab event-source specification is available [here](https://github.com/argoproj/argo-events/blob/master/api/event-source.md#gitlabeventsource). <br />
    28  Example event-source yaml file is [here](https://github.com/argoproj/argo-events/blob/master/examples/event-sources/gitlab.yaml).
    29  
    30  ## Setup
    31  
    32  1. Create an API token if you don't have one. Follow [instructions](https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html) to create a new GitLab API Token.
    33     Grant it the `api` permissions.
    34  
    35  1. Base64 encode your api token key.
    36  
    37          echo -n <api-token-key> | base64
    38  
    39  1. Create a secret called `gitlab-access`.
    40  
    41          apiVersion: v1
    42          kind: Secret
    43          metadata:
    44            name: gitlab-access
    45          type: Opaque
    46          data:
    47            token: <base64-encoded-api-token-from-previous-step>
    48  
    49  1. Deploy the secret into K8s cluster.
    50  
    51          kubectl -n argo-events apply -f gitlab-access.yaml
    52  
    53  1. The event-source for GitLab creates a pod and exposes it via service.
    54     The name for the service is in `<event-source-name>-eventsource-svc` format.
    55     You will need to create an Ingress or OpenShift Route for the event-source service so that it can be reached from GitLab.
    56     You can find more information on Ingress or Route online.
    57  
    58  1. Create the event source by running the following command. Make sure to update `url` field.
    59  
    60          kubectl apply -n argo-events -f <event-source-file-updated-in-previous-step>
    61  
    62  1. Go to `Webhooks` under your project settings on GitLab and verify the webhook is registered.
    63  
    64  1. Create the sensor by running the following command.
    65  
    66          kubectl apply -n argo-events -f https://raw.githubusercontent.com/argoproj/argo-events/stable/examples/sensors/gitlab.yaml
    67  
    68  1. Make a change to one of your project files and commit. It will trigger an argo workflow.
    69  
    70  1. Run `argo list` to find the workflow.
    71  
    72  ## Troubleshoot
    73  
    74  Please read the [FAQ](https://argoproj.github.io/argo-events/FAQ/).