GitLab CI Events Proposal 4: Defining subscriptions in a dedicated configuration file

Each project can have its own configuration file for defining subscriptions to events. For example, .gitlab-ci-event.yml. In this file, we can define events in the following format:

events:
  - package/published
  - issue/created

When this file is changed in the project repository, it is parsed and the events are created, updated, or deleted. This is highly similar to Proposal 1 except that we don’t need to track pipeline creations every time.

  1. Upsert events to the database when .gitlab-ci-event.yml gets updated.
  2. Create inline reactions to events in code to trigger pipelines.

Filtering jobs

We can filter jobs by using the rules keyword. For example:

test_package_published:
  script: echo testing published package
  rules:
    - events: ["package/published"]

test_package_removed:
  script: echo testing removed package
  rules:
    - events: ["package/removed"]

Otherwise, we can make it work either a CI variable;

test_package_published:
  script: echo testing published package
  rules:
    - if: $CI_EVENT == "package/published"

test_package_removed:
  script: echo testing removed package
  rules:
    - if: $CI_EVENT == "package/removed"

or an input like in the Proposal 3:

spec:
  inputs:
    event:
      default: push

---

test_package_published:
  script: echo testing published package
  rules:
    - if: $[[ inputs.event ]] == "package/published"

test_package_removed:
  script: echo testing removed package
  rules:
    - if: $[[ inputs.event ]] == "package/removed"

Challenges

  1. This will not work on GitLab.com scale.
Last modified August 23, 2024: Ensure frontmatter is consistent (e47101dc)