Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

docs(autopilots): explain GitLab webhook action filters (MUL-9480) (#10809)

Bohan Jiangaefd8ac7c08f
diff --git a/apps/docs/content/docs/autopilots.fr.mdx b/apps/docs/content/docs/autopilots.fr.mdx
index 1c8fa12e91..d93a5c7c74 100644
--- a/apps/docs/content/docs/autopilots.fr.mdx
+++ b/apps/docs/content/docs/autopilots.fr.mdx
@@ -91,6 +91,19 @@ Lorsqu'une même source envoie plusieurs types d'événements, ajoutez des filtr
Par exemple, avec `workflow_run` comme nom d'événement et `completed, failed` comme actions, seuls ces deux types de résultats `workflow_run` sont acceptés. Multica reconnaît l'événement et l'action à partir des en-têtes de requête et des champs de charge utile courants, notamment l'en-tête `X-GitHub-Event` de GitHub et le champ `action` du corps.
+Pour GitLab, le nom d'événement est la valeur de l'en-tête `X-Gitlab-Event` telle que GitLab l'envoie, par exemple `Merge Request Hook`, `Issue Hook` ou `Note Hook`, espaces et majuscules compris ; le champ `object_kind` de la charge utile (`merge_request`) ne correspond pas. Chaque action listée est comparée à la fois à `object_attributes.action` et à `object_attributes.state`, et la règle correspond si l'une des deux valeurs figure dans la liste. Cette règle accepte les merge requests créées, mises à jour ou rouvertes, et ignore les fusions et fermetures :
+
+```json
+{ "event": "Merge Request Hook", "actions": ["open", "update", "reopen"] }
+```
+
+Indiquez des verbes d'action (`open`, `update`, `reopen`, `merge`, `close`) plutôt que des états (`opened`, `merged`, `closed`). Les valeurs sont comparées à l'identique et jamais converties d'une forme à l'autre, et un état correspond à tout événement qui laisse l'objet dans cet état. Pousser un commit sur une merge request ouverte envoie `"action": "update"` avec `"state": "opened"`, et une approbation envoie `"action": "approval"` avec le même état : avec `opened`, chacun de ces événements lance donc une exécution, en plus des nouvelles merge requests.
+
+- `Issue Hook` avec `close` accepte les tickets fermés.
+- `Note Hook` avec `create` accepte les nouveaux commentaires ; un commentaire modifié envoie `update`.
+- Une règle GitLab sans actions accepte tous les événements portant ce nom.
+- Les hooks de pipeline et de job indiquent leur résultat dans `object_attributes.status` et `build_status`, qui ne sont pas lus comme des actions. Laissez les actions vides et ajoutez plutôt une condition sur ce champ, par exemple `object_attributes.status` égal à `failed`.
+
Chaque règle peut aussi porter des `conditions` sur les champs de la charge utile : cliquez sur **Ajouter une condition** dans la règle, ou définissez-les via l'API. Toutes les conditions doivent être vraies pour que la règle corresponde ; un événement filtré est ignoré avant le démarrage de toute exécution. `path` parcourt la charge utile avec des points : un nombre indexe un tableau et `*` désigne n'importe quel élément (`pull_request.labels.*.name`). `op` vaut `equals`, `not_equals`, `contains`, `in` ou `exists`, et `ignore_case` s'applique au texte. Avec `*`, `equals`, `contains`, `in` et `exists` sont vraies si un élément correspond, et `not_equals` si aucun ne correspond. Un champ absent ne correspond jamais, et `exists` ignore `null`. Par exemple, cette règle n'accepte que les pull requests prêtes, étiquetées `needs-review`, qui ciblent `main` ou `release` et n'ont pas été ouvertes par un bot :
```json
diff --git a/apps/docs/content/docs/autopilots.ja.mdx b/apps/docs/content/docs/autopilots.ja.mdx
index 608886603f..466808e52d 100644
--- a/apps/docs/content/docs/autopilots.ja.mdx
+++ b/apps/docs/content/docs/autopilots.ja.mdx
@@ -91,6 +91,19 @@ Webhook リクエストには次の制約があります。
たとえばイベント名に `workflow_run`、Actions に `completed, failed` を指定すると、この 2 種類の `workflow_run` の結果だけを受け取ります。Multica は一般的なリクエストヘッダーと payload からイベントと action を判定します。GitHub の `X-GitHub-Event` と body の `action` にも対応しています。
+GitLab の場合、イベント名は GitLab が送る `X-Gitlab-Event` リクエストヘッダーの値そのもので、`Merge Request Hook`、`Issue Hook`、`Note Hook` のように空白や大文字も含めて一致させます。payload の `object_kind`(`merge_request`)では一致しません。Actions の各値は `object_attributes.action` と `object_attributes.state` の両方と比較され、どちらかが一致すればルールに一致します。次のルールは新規作成・更新・再オープンされた merge request を受け取り、マージとクローズは無視します。
+
+```json
+{ "event": "Merge Request Hook", "actions": ["open", "update", "reopen"] }
+```
+
+Actions には状態を表す語(`opened`、`merged`、`closed`)ではなく、操作を表す語(`open`、`update`、`reopen`、`merge`、`close`)を指定してください。値は完全一致で比較され、一方の形から他方へ変換されることはありません。状態を表す語は、対象をその状態のままにするすべてのイベントに一致します。オープン中の merge request にコミットを push すると `"action": "update"` と `"state": "opened"` が、承認すると `"action": "approval"` と同じ状態が送られるため、`opened` を指定すると新規作成に加えてこれらのイベントでも実行が始まります。
+
+- `Issue Hook` に `close` を指定すると、クローズされた issue を受け取ります。
+- `Note Hook` に `create` を指定すると、新しいコメントを受け取ります。コメントの編集では `update` が送られます。
+- Actions が空の GitLab ルールは、そのイベント名のすべてのイベントを受け取ります。
+- Pipeline Hook と Job Hook の結果はそれぞれ `object_attributes.status` と `build_status` にあり、action としては読み取られません。Actions を空にして、そのフィールドに条件を追加してください(例: `object_attributes.status` が `failed` に等しい)。
+
各ルールには payload のフィールドに対する `conditions` も設定できます。ルールの **条件を追加** をクリックするか、API から設定します。すべての条件を満たしたときだけそのルールに一致し、除外されたイベントは実行が始まる前に無視されます。`path` はドット区切りで payload をたどり、数値は配列の添字、`*` は任意の要素を表します(`pull_request.labels.*.name`)。`op` は `equals`、`not_equals`、`contains`、`in`、`exists` のいずれかで、`ignore_case` はテキストに適用されます。`*` を使う場合、`equals`、`contains`、`in`、`exists` はいずれかの要素が一致すれば成立し、`not_equals` はどの要素も一致しないときに成立します。フィールドが存在しない場合は一致せず、`exists` は `null` を無視します。たとえば次のルールは、準備ができていて `needs-review` ラベルが付き、`main` または `release` を対象とし、bot が作成したものではない pull request だけを受け取ります。
```json
diff --git a/apps/docs/content/docs/autopilots.ko.mdx b/apps/docs/content/docs/autopilots.ko.mdx
index 521bdf94fe..b46b7699b1 100644
--- a/apps/docs/content/docs/autopilots.ko.mdx
+++ b/apps/docs/content/docs/autopilots.ko.mdx
@@ -91,6 +91,19 @@ Webhook 요청에는 다음 제약이 있습니다.
예를 들어 이벤트 이름에 `workflow_run`, Actions에 `completed, failed`를 입력하면 이 두 종류의 `workflow_run` 결과만 받습니다. Multica는 GitHub의 `X-GitHub-Event`와 body의 `action`을 포함해 일반적인 요청 header와 payload에서 이벤트와 action을 식별합니다.
+GitLab의 이벤트 이름은 GitLab이 보내는 `X-Gitlab-Event` 요청 header 값 그대로이며, `Merge Request Hook`, `Issue Hook`, `Note Hook`처럼 공백과 대소문자까지 일치해야 합니다. payload의 `object_kind`(`merge_request`)로는 일치하지 않습니다. Actions의 각 값은 `object_attributes.action`과 `object_attributes.state` 모두와 비교되며, 둘 중 하나라도 같으면 규칙이 일치합니다. 아래 규칙은 새로 만들어지거나 업데이트되거나 다시 열린 merge request를 받고, 병합과 닫기는 무시합니다.
+
+```json
+{ "event": "Merge Request Hook", "actions": ["open", "update", "reopen"] }
+```
+
+Actions에는 상태 단어(`opened`, `merged`, `closed`)가 아니라 동작 단어(`open`, `update`, `reopen`, `merge`, `close`)를 입력하세요. 값은 정확히 비교되며 한 형태가 다른 형태로 변환되지 않습니다. 상태 단어는 대상을 그 상태로 두는 모든 이벤트와 일치합니다. 열린 merge request에 커밋을 push하면 `"action": "update"`와 `"state": "opened"`가, 승인하면 `"action": "approval"`와 같은 상태가 전송되므로, `opened`를 입력하면 새 merge request뿐 아니라 이런 이벤트마다 실행이 시작됩니다.
+
+- `Issue Hook`에 `close`를 지정하면 닫힌 issue를 받습니다.
+- `Note Hook`에 `create`를 지정하면 새 댓글을 받습니다. 댓글을 수정하면 `update`가 전송됩니다.
+- Actions가 비어 있는 GitLab 규칙은 해당 이벤트 이름의 모든 이벤트를 받습니다.
+- Pipeline Hook과 Job Hook은 결과를 각각 `object_attributes.status`와 `build_status`에 담으며, 이 값은 action으로 읽히지 않습니다. Actions를 비워 두고 해당 필드에 조건을 추가하세요. 예: `object_attributes.status`가 `failed`와 같음.
+
각 규칙에는 payload 필드에 대한 `conditions`도 지정할 수 있습니다. 규칙의 **조건 추가**를 클릭하거나 API로 설정하세요. 모든 조건을 만족해야 해당 규칙이 일치하며, 걸러진 이벤트는 실행이 시작되기 전에 무시됩니다. `path`는 점으로 payload를 따라가며, 숫자는 배열 인덱스이고 `*`는 임의의 요소를 뜻합니다(`pull_request.labels.*.name`). `op`는 `equals`, `not_equals`, `contains`, `in`, `exists` 중 하나이며, `ignore_case`는 텍스트에 적용됩니다. `*`를 쓰면 `equals`, `contains`, `in`, `exists`는 요소 하나라도 일치하면 성립하고, `not_equals`는 어떤 요소도 일치하지 않을 때 성립합니다. 필드가 없으면 일치하지 않으며, `exists`는 `null`을 무시합니다. 예를 들어 아래 규칙은 준비된 상태이고 `needs-review` 라벨이 있으며 `main` 또는 `release`를 대상으로 하고 봇이 열지 않은 pull request만 받습니다.
```json
diff --git a/apps/docs/content/docs/autopilots.mdx b/apps/docs/content/docs/autopilots.mdx
index 18def415e6..19e63b6d26 100644
--- a/apps/docs/content/docs/autopilots.mdx
+++ b/apps/docs/content/docs/autopilots.mdx
@@ -91,6 +91,19 @@ When one source sends several event types, add event filters to the trigger. Cli
For example, with `workflow_run` as the event name and `completed, failed` as the actions, only those two kinds of `workflow_run` results are accepted. Multica recognizes the event and action from common request headers and payload fields, including GitHub's `X-GitHub-Event` and the `action` field in the body.
+For GitLab, the event name is the `X-Gitlab-Event` header value exactly as GitLab sends it, such as `Merge Request Hook`, `Issue Hook`, or `Note Hook`, including spaces and capitals; the payload's `object_kind` (`merge_request`) doesn't match. Each listed action is compared with both `object_attributes.action` and `object_attributes.state`, and the rule matches if either value is listed. This rule accepts new, updated, and reopened merge requests and ignores merges and closes:
+
+```json
+{ "event": "Merge Request Hook", "actions": ["open", "update", "reopen"] }
+```
+
+List action words (`open`, `update`, `reopen`, `merge`, `close`) rather than state words (`opened`, `merged`, `closed`). Values are compared exactly and never translated from one form to the other, and a state word matches every event that leaves the object in that state. Pushing a commit to an open merge request sends `"action": "update"` with `"state": "opened"`, and an approval sends `"action": "approval"` with the same state, so `opened` starts a run for each of these as well as for new merge requests.
+
+- `Issue Hook` with `close` accepts closed issues.
+- `Note Hook` with `create` accepts new comments; edited comments send `update`.
+- A GitLab rule with no actions accepts every event with that event name.
+- Pipeline and job hooks report their result in `object_attributes.status` and `build_status`, which aren't read as actions. Leave the actions empty and add a condition on that field instead, for example `object_attributes.status` equals `failed`.
+
Each rule can also carry `conditions` on payload fields: click **Add condition** on the rule, or set them through the API. Every condition must hold for the rule to match; a filtered event is ignored before any run starts. `path` walks the payload with dots, where a number indexes an array and `*` means any element (`pull_request.labels.*.name`). `op` is `equals`, `not_equals`, `contains`, `in` or `exists`, and `ignore_case` applies to text. With `*`, `equals`, `contains`, `in` and `exists` hold if any element matches, and `not_equals` holds if none does. A missing field never matches, and `exists` ignores `null`. For example, this rule only accepts ready pull requests labelled `needs-review` that target `main` or `release` and weren't opened by a bot:
```json
diff --git a/apps/docs/content/docs/autopilots.zh-Hant.mdx b/apps/docs/content/docs/autopilots.zh-Hant.mdx
index 97c7fd75a1..6378929cb5 100644
--- a/apps/docs/content/docs/autopilots.zh-Hant.mdx
+++ b/apps/docs/content/docs/autopilots.zh-Hant.mdx
@@ -91,6 +91,19 @@ Webhook 請求的約束:
例如,事件名填寫 `workflow_run`,Actions 填寫 `completed, failed`,只會接收這兩類 `workflow_run` 結果。Multica 會從常見請求頭和 payload 中識別事件與 action,包括 GitHub 的 `X-GitHub-Event` 和 body 中的 `action`。
+GitLab 的事件名就是 GitLab 傳送的 `X-Gitlab-Event` 請求頭原值,例如 `Merge Request Hook`、`Issue Hook`、`Note Hook`,空格和大小寫都要一致;payload 裡的 `object_kind`(`merge_request`)不會命中。Actions 中的每個值會同時與 `object_attributes.action` 和 `object_attributes.state` 比較,任意一個相等即命中。下面這條規則接收新建、更新和重新開啟的 merge request,忽略合併和關閉:
+
+```json
+{ "event": "Merge Request Hook", "actions": ["open", "update", "reopen"] }
+```
+
+Actions 請填寫動作詞(`open`、`update`、`reopen`、`merge`、`close`),不要填寫狀態詞(`opened`、`merged`、`closed`)。比對是精確比較,兩種寫法之間不會互相轉換;狀態詞會命中所有讓物件處於該狀態的事件。向開啟中的 merge request 推送提交會傳送 `"action": "update"` 和 `"state": "opened"`,核准會傳送 `"action": "approval"` 和同樣的狀態,所以填寫 `opened` 時,這些事件和新建 merge request 一樣都會啟動執行。
+
+- `Issue Hook` 加 `close`:接收被關閉的 issue。
+- `Note Hook` 加 `create`:接收新留言;編輯留言傳送的是 `update`。
+- GitLab 規則的 Actions 留空時,接收該事件名下的所有事件。
+- Pipeline Hook 和 Job Hook 的結果分別在 `object_attributes.status` 和 `build_status` 中,不會被當作 action 讀取。請把 Actions 留空,再對該欄位新增條件,例如 `object_attributes.status` 等於 `failed`。
+
每條規則還可以設定針對本文欄位的 `conditions`:點選該規則的 **新增條件**,或透過 API 設定。同一條規則的全部條件都要符合,多條規則之間符合任意一條即可。`path` 用點號存取事件本文,數字表示陣列索引,`*` 表示任意元素(例如 `pull_request.labels.*.name`)。操作支援 `equals`、`not_equals`、`contains`、`in` 和 `exists`,`ignore_case` 忽略文字大小寫。使用 `*` 時,前四種操作中除 `not_equals` 外,只要有一個元素符合即可;`not_equals` 要求沒有元素等於指定值。`exists` 忽略 `null`。字串與布林值必須使用正確類型,例如 `"false"` 與 `false` 不同。
```json
diff --git a/apps/docs/content/docs/autopilots.zh.mdx b/apps/docs/content/docs/autopilots.zh.mdx
index 59e3374a7f..bc54517675 100644
--- a/apps/docs/content/docs/autopilots.zh.mdx
+++ b/apps/docs/content/docs/autopilots.zh.mdx
@@ -91,6 +91,19 @@ Webhook 请求的约束:
例如,事件名填写 `workflow_run`,Actions 填写 `completed, failed`,只会接收这两类 `workflow_run` 结果。Multica 会从常见请求头和 payload 中识别事件与 action,包括 GitHub 的 `X-GitHub-Event` 和 body 中的 `action`。
+GitLab 的事件名就是 GitLab 发送的 `X-Gitlab-Event` 请求头原值,例如 `Merge Request Hook`、`Issue Hook`、`Note Hook`,空格和大小写都要一致;payload 里的 `object_kind`(`merge_request`)不会命中。Actions 中的每个值会同时与 `object_attributes.action` 和 `object_attributes.state` 比较,任意一个相等即命中。下面这条规则接收新建、更新和重新打开的 merge request,忽略合并和关闭:
+
+```json
+{ "event": "Merge Request Hook", "actions": ["open", "update", "reopen"] }
+```
+
+Actions 请填写动作词(`open`、`update`、`reopen`、`merge`、`close`),不要填写状态词(`opened`、`merged`、`closed`)。匹配是精确比较,两种写法之间不会互相转换;状态词会命中所有让对象处于该状态的事件。向打开的 merge request 推送提交会发送 `"action": "update"` 和 `"state": "opened"`,批准会发送 `"action": "approval"` 和同样的状态,所以填写 `opened` 时,这些事件和新建 merge request 一样都会启动运行。
+
+- `Issue Hook` 加 `close`:接收被关闭的 issue。
+- `Note Hook` 加 `create`:接收新评论;编辑评论发送的是 `update`。
+- GitLab 规则的 Actions 留空时,接收该事件名下的所有事件。
+- Pipeline Hook 和 Job Hook 的结果分别在 `object_attributes.status` 和 `build_status` 中,不会被当作 action 读取。请把 Actions 留空,再对该字段添加条件,例如 `object_attributes.status` 等于 `failed`。
+
每条规则还可以设置针对 payload 字段的 `conditions`:点击该规则的 **添加条件**,或通过 API 设置。所有条件都满足时该规则才命中;被过滤的事件在任何运行开始前就会被忽略。`path` 用点号访问 payload,数字表示数组下标,`*` 表示任意元素(`pull_request.labels.*.name`)。`op` 可选 `equals`、`not_equals`、`contains`、`in` 或 `exists`,`ignore_case` 作用于文本。使用 `*` 时,`equals`、`contains`、`in` 和 `exists` 只要有一个元素匹配即成立,`not_equals` 要求没有任何元素匹配。字段不存在时永远不命中,`exists` 会忽略 `null`。例如,下面这条规则只接收已就绪、带有 `needs-review` 标签、目标分支为 `main` 或 `release`、且不是由机器人创建的 pull request:
```json