--- title: "ADR 0078: How on-cel-expression is evaluated against an event" --- * Status: accepted * Code: [`pkg/matcher/cel.go`](https://github.com/tektoncd/pipelines-as-code/blob/main/pkg/matcher/cel.go), [`pkg/matcher/cel_ast.go`](https://github.com/tektoncd/pipelines-as-code/blob/main/pkg/matcher/cel_ast.go), [`pkg/matcher/errors.go`](https://github.com/tektoncd/pipelines-as-code/blob/main/pkg/matcher/errors.go), [`pkg/matcher/annotation_matcher.go`](https://github.com/tektoncd/pipelines-as-code/blob/main/pkg/matcher/annotation_matcher.go) ## Context `on-cel-expression` replaces `on-event`/`on-target-branch` matching. Several event shapes would otherwise make a naive evaluation wrong or costly: push events carry `refs/heads/` in branch names, fetching changed files costs a provider API call, and label events fire for every label change. ## Decision * The expression's AST is inspected instead of its text. On push events, `target_branch` / `source_branch` have `refs/heads/` stripped only when the expression references that variable and contains no `"refs/heads/"` string literal. * Changed files are fetched (`GetFiles`) only when the expression references `files`. * For `pull_request_labeled` events, an expression that references none of `event_type`, `labels` or `pull_request_labels` (dot or bracket access) evaluates to false, so generic `event == "pull_request"` expressions do not match label add/remove events. * A custom parameter named like a standard variable is ignored and a `CELParamConflict` warning event is emitted. * Evaluation errors from parse, check, program creation or evaluation are reported. With the comment strategy `update` they go to a status comment keyed by the PipelineRun name; otherwise they are collected and reported once. Pipes and newlines in the error are escaped so the markdown table keeps its layout. * When `on-cel-expression` is present, `on-event` and `on-target-branch` are ignored and a warning is emitted. ## Consequences * A generic expression such as `event == "pull_request"` never matches a label event; it must mention labels or `event_type`. * An expression that writes `"refs/heads/"` anywhere gets the unstripped branch names on push events. * Custom parameters cannot override the variables listed in `standardParams`.