GitLab Pipelines Trigger

GitLab Pipelines Trigger

Certified

Trigger a flow when a GitLab pipeline finishes

Polls the most recently updated pipelines of a project and starts one execution with every pipeline that reached one of the watched statuses since the last poll. Pipelines already seen are kept in the trigger state, so each one fires once.

The first poll, when the state is empty, only records the pipelines that already finished and starts no execution, so the trigger does not fire on pipelines that ended before it was created.

Every later poll asks GitLab only for the pipelines updated since the latest one recorded in the state (minus a one-minute overlap) and pages through them up to maxPipelines; set maxPipelines above the number of pipelines updated during one interval on busy projects so none is missed.

yaml
type: io.kestra.plugin.gitlab.pipelines.Trigger

Log every pipeline of main that succeeded, failed or was canceled.

yaml
id: gitlab_pipeline_finished
namespace: company.team

triggers:
  - id: on_pipeline_finished
    type: io.kestra.plugin.gitlab.pipelines.Trigger
    token: "{{ secret('GITLAB_TOKEN') }}"
    projectId: "12345"
    ref: main
    interval: PT1M

tasks:
  - id: handle_event
    type: io.kestra.plugin.core.log.Log
    message: "Pipeline {{ trigger.pipeline.id }} ended with {{ trigger.pipeline.status }}: {{ trigger.pipeline.webUrl }}"

Alert on failed pipelines only, inspecting up to 50 updated pipelines per poll.

yaml
id: gitlab_pipeline_failed
namespace: company.team

triggers:
  - id: on_pipeline_failed
    type: io.kestra.plugin.gitlab.pipelines.Trigger
    token: "{{ secret('GITLAB_TOKEN') }}"
    projectId: "12345"
    statuses:
      - FAILED
    maxPipelines: 50
    interval: PT2M

tasks:
  - id: log_failures
    type: io.kestra.plugin.core.log.Log
    message: "{{ trigger.total }} pipeline(s) failed, latest: {{ trigger.pipeline.webUrl }}"
Properties

Project ID or path

Numeric project ID or URL-encoded project path.

Access token used for API calls

GitLab Personal/Project/Group Access Token with the read_api scope, sent as the PRIVATE-TOKEN header.

Defaultfalse

Specifies whether a trigger is allowed to start a new execution even if a previous run is still in progress.

Default/api/v4/projects

Projects API path

Projects API prefix appended before the project ID; defaults to /api/v4/projects.

DefaultPT1M
Formatduration

Interval between polling.

The interval between 2 different polls of schedule, this can avoid to overload the remote system with too many calls. For most of the triggers that depend on external systems, a minimal interval must be at least PT30S. See ISO_8601 Durations for more information of available interval values.

Default20

Maximum pipelines per poll

Maximum number of updated pipelines inspected on each poll, most recently updated first. Defaults to 20; must be between 1 and 100.

DefaultCREATE
Possible Values
CREATEUPDATECREATE_OR_UPDATE

State change mode

CREATE fires once per pipeline, UPDATE also fires again when a watched pipeline changes status, for example after a retry.

Ref filter

Only watch pipelines of this branch or tag.

State key

Custom key used to store the pipelines already seen.

DefaultPT168H

State TTL

How long the pipelines already seen are remembered. Defaults to P7D and must be at least twice the polling interval, otherwise the state expires between two polls and new pipelines are never reported. The updated_after watermark already keeps older pipelines from being listed again, so the state only needs to cover recent ones. If the trigger is paused for longer than stateTtl, the state expires and the next poll starts over as a first poll: it records the pipelines that finished meanwhile without starting an execution.

SubTypestring
Default["SUCCESS","FAILED","CANCELED"]
Possible Values
CREATEDWAITING_FOR_RESOURCEPREPARINGPENDINGRUNNINGCANCELINGSUCCESSFAILEDCANCELEDSKIPPEDMANUALSCHEDULED

Watched statuses

Pipeline statuses that start an execution. Defaults to SUCCESS, FAILED and CANCELED.

SubTypestring
Possible Values
CREATEDSUBMITTEDRUNNINGPAUSEDRESTARTEDKILLINGSUCCESSWARNINGFAILEDKILLEDCANCELLEDQUEUEDRETRYINGRETRIEDSKIPPEDBREAKPOINTRESUBMITTED

List of execution states after which a trigger should be stopped (a.k.a. disabled).

Defaulthttps://gitlab.com

GitLab API base URL

Base URL of the GitLab instance; defaults to https://gitlab.com. Override for self-hosted installations.

Defaulttrue

A condition that determines whether the trigger should run.

A Pebble expression evaluated at trigger time. The trigger fires only when the expression evaluates to a truthy value (true, a non-empty string, a non-zero number). Use this to gate trigger execution on dynamic runtime values such as execution labels, flow variables, or environment conditions.

First pipeline

The most recently updated pipeline that reached a watched status.

Definitions
createdAtstring
Formatdate-time

Creation time

durationinteger

Duration in seconds

Time the pipeline spent running; empty while it is still running.

finishedAtstring
Formatdate-time

Finish time

Empty while the pipeline is still running.

idinteger

Pipeline ID

Global ID of the pipeline, used in the pipeline API endpoints.

iidinteger

Pipeline IID

ID of the pipeline within its project, as shown in the GitLab UI (#12).

projectIdinteger

Project ID

Numeric ID of the project the pipeline belongs to.

refstring

Git ref

Branch or tag the pipeline runs for.

shastring

Commit SHA

SHA of the commit the pipeline runs for.

sourcestring

Pipeline source

What started the pipeline, for example push, web, api, schedule or merge_request_event.

startedAtstring
Formatdate-time

Start time

Empty while the pipeline has not started.

statusstring

Pipeline status

One of created, waiting_for_resource, preparing, pending, running, canceling, success, failed, canceled, skipped, manual or scheduled.

updatedAtstring
Formatdate-time

Last update time

webUrlstring

Pipeline URL

Link to the pipeline in the GitLab UI.

Pipelines

Every pipeline that reached a watched status since the last poll, most recently updated first.

Definitions
createdAtstring
Formatdate-time

Creation time

durationinteger

Duration in seconds

Time the pipeline spent running; empty while it is still running.

finishedAtstring
Formatdate-time

Finish time

Empty while the pipeline is still running.

idinteger

Pipeline ID

Global ID of the pipeline, used in the pipeline API endpoints.

iidinteger

Pipeline IID

ID of the pipeline within its project, as shown in the GitLab UI (#12).

projectIdinteger

Project ID

Numeric ID of the project the pipeline belongs to.

refstring

Git ref

Branch or tag the pipeline runs for.

shastring

Commit SHA

SHA of the commit the pipeline runs for.

sourcestring

Pipeline source

What started the pipeline, for example push, web, api, schedule or merge_request_event.

startedAtstring
Formatdate-time

Start time

Empty while the pipeline has not started.

statusstring

Pipeline status

One of created, waiting_for_resource, preparing, pending, running, canceling, success, failed, canceled, skipped, manual or scheduled.

updatedAtstring
Formatdate-time

Last update time

webUrlstring

Pipeline URL

Link to the pipeline in the GitLab UI.

Number of pipelines