> ## Documentation Index
> Fetch the complete documentation index at: https://docs.vikingqa.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Start a flow from a GitLab event

> Run the agent when a merge request, a push or a pipeline happens in GitLab.

## Before you start

* GitLab is [connected and granted](/integrations/gitlab) to your vikingQA
  project.
* The GitLab user who connected has the **Maintainer** or **Owner**
  [role](https://docs.gitlab.com/user/permissions/) on the GitLab project.

## Set it up

<Steps>
  <Step title="Create the flow">
    Open **Flows**, select **Create flow**, then **Run an AI agent on a GitLab
    event**.
  </Step>

  <Step title="Set the trigger">
    Under **Trigger**, choose:

    * **GitLab connection** and **Project**
    * **Event type**: see [Events](#events)
    * **With the following branches as target** (merge requests) or **On the
      following branches** (push, pipeline): **All branches** or **Selected
      branches**
    * **Environment**: where the agent works

    Select **Save**.
  </Step>

  <Step title="Tell the agent what to do">
    Under **Action**, fill in **Instructions for the agent** and save.
  </Step>

  <Step title="Turn it on">
    A new flow is off. Switch **Status** to **Enabled**.
  </Step>
</Steps>

## Events

| Event type | Starts the flow when | Branch matched | The agent receives |
| - | - | - | - |
| Merge request | A merge request is opened, reopened or updated | Target branch | Title and link, author, source and target branches |
| Push (commit) | Someone pushes commits | Pushed branch | Branch, latest commit, commit count, who pushed |
| Pipeline succeeded | A pipeline passes. A re-run that passes counts too. | Pipeline's branch | Branch and commit |

For merge requests, pick which of **Opened**, **Re-opened** and **Updated**
start the flow. Pipelines that run on a tag count only when **All branches** is
selected.

## Troubleshooting

### The flow doesn't start

vikingQA adds a
[webhook](https://docs.gitlab.com/user/project/integrations/webhooks/) to the
GitLab project when you grant access. Check it exists in GitLab under
**Settings → Webhooks**.

If it's missing:

1. Give the GitLab user who connected the role listed in
   [Before you start](#before-you-start).
2. In vikingQA, open **Project settings → MCPs**, select **Configure** next to
   GitLab, then **Save access**. This adds the webhook again.
