Add pipeline event type to flow triggers

What does this MR do and why?

Add the ability to trigger a flow when a pipeline event (status change) occurs

References

Flow Triggers - Pipeline Failure Trigger (#567784 - closed)

Screenshots or screen recordings

How to set up and validate locally

  1. Enable the :ai_flow_trigger_pipeline_hooks feature flag
  2. Create a custom flow:
# Schema version
version: "v1"
# Environment where the flow runs (ambient = GitLab's managed environment)
environment: ambient

# Components define the steps in your flow
# Each component can be an Agent, DeterministicStep, or other component types
components:
  - name: "my_agent"
    type: AgentComponent  # Options: AgentComponent, DeterministicStepComponent
    prompt_id: "my_prompt"  # References a prompt defined below
    inputs:
      - "context:goal"  # Input from user or previous component
    toolset:
      - list_issues
      - get_issue
      - create_issue
      - create_issue_note
      # Add tool names here: ["get_issue", "create_issue_note"]

    # Optional: Add UI logging for debugging
    # ui_log_events:
    #   - "on_agent_final_answer"
    #   - "on_tool_execution_success"

# Define your prompts here
# Each prompt configures an AI agent's behavior and model settings
prompts:
  - prompt_id: "my_prompt"  # Must match the prompt_id referenced above
    name: "My Agent Prompt"
    unit_primitives:
      - duo_chat

    # System and user prompts define the agent's behavior
    prompt_template:
      system: |
        You are GitLab Duo Chat, an agentic AI assistant.
        Your role is to help users with their GitLab pipelines.
        Be concise, accurate, and actionable in your responses.

        Only analyze pipelines which are complete (finished, successful, or failed).
        We are not interested in running/created/pending etc.

        Look for an issue with the title "Pipeline observations" (create a new issue if one doesn't already exist).
        Add a comment to the issue with a link to the pipeline and the observations found.
      user: |
        {{goal}}

      placeholder: history  # Maintains conversation context

    params:
      timeout: 180  # Seconds before timeout

# Routers define the flow between components
# Use "end" as the final destination
routers:
  - from: "my_agent"
    to: "end"

  # Example: Multi-step flow
  # - from: "fetch_data"
  #   to: "process_data"
  # - from: "process_data"
  #   to: "my_agent"
  # - from: "my_agent"
  #   to: "end"

# Define the entry point for your flow
flow:
  entry_point: "my_agent"
  1. Enable the flow in a group
  2. Enable the flow in a project (enabling the pipeline events trigger)
  3. Trigger a pipeline in the project
  4. You should see 4 pipelines (the pipeline you triggered, plus 3 workloads):

image

  1. And the 3 sessions (1 when the pipeline entered the created state, 1 for the running state, and one for the finished state):

image

  1. Break the pipeline (I selected an invalid image)
  2. Look at the issues for the project and you should see it's created one as described in the flow prompt with details of the passing and failing pipeliens:

image

image

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Lee Tickett

Merge request reports

Loading