You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(cel): add direct custom param variable access
Allow custom parameters from Repository CR to be accessed directly as
CEL variables without template expansion. Parameters can now be used
as: param_name == "value" on top of "{{param_name}}" == "value".
Jira: https://issues.redhat.com/browse/SRVKP-9118
Signed-off-by: Akshay Pant <akshay.akshaypant@gmail.com>
Copy file name to clipboardExpand all lines: docs/content/docs/guide/customparams.md
+66Lines changed: 66 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -122,3 +122,69 @@ and a pull request event.
122
122
- [GitHub Documentation for webhook events](https://docs.github.com/webhooks-and-events/webhooks/webhook-events-and-payloads?actionType=auto_merge_disabled#pull_request)
123
123
- [GitLab Documentation for webhook events](https://docs.gitlab.com/ee/user/project/integrations/webhook_events.html)
124
124
{{< /hint >}}
125
+
126
+
### Using custom parameters in CEL matching expressions
127
+
128
+
In addition to template expansion (`{{ param }}`), custom parameters defined in the Repository CR are available as CEL variables in the `on-cel-expression` annotation. This allows you to control which PipelineRuns are triggered based on repository-specific configuration.
129
+
130
+
For example, with this Repository CR configuration:
131
+
132
+
```yaml
133
+
apiVersion: "pipelinesascode.tekton.dev/v1alpha1"
134
+
kind: Repository
135
+
metadata:
136
+
name: my-repo
137
+
spec:
138
+
url: "https://github.com/owner/repo"
139
+
params:
140
+
- name: enable_ci
141
+
value: "true"
142
+
- name: environment
143
+
value: "staging"
144
+
```
145
+
146
+
You can use these parameters directly in your PipelineRun's CEL expression:
- **Conditional CI**: Enable or disable CI for specific repositories without changing PipelineRun files
163
+
- **Environment-specific matching**: Run different pipelines based on environment configuration
164
+
- **Feature flags**: Control which pipelines run using repository-level feature flags
165
+
166
+
Custom parameters from secrets are also available:
167
+
168
+
```yaml
169
+
spec:
170
+
params:
171
+
- name: api_key
172
+
secret_ref:
173
+
name: my-secret
174
+
key: key
175
+
```
176
+
177
+
```yaml
178
+
179
+
apiVersion: tekton.dev/v1
180
+
kind: PipelineRun
181
+
metadata:
182
+
name: my-pipeline-with-secret
183
+
annotations:
184
+
pipelinesascode.tekton.dev/on-cel-expression: |
185
+
event == "push" && api_key != ""
186
+
spec:
187
+
# ... pipeline spec
188
+
```
189
+
190
+
For more information on CEL expressions and event matching, see the [Advanced event matching using CEL]({{< relref "/docs/guide/matchingevents#advanced-event-matching-using-cel" >}}) documentation.
Copy file name to clipboardExpand all lines: docs/content/docs/guide/matchingevents.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -309,6 +309,7 @@ The fields available are:
309
309
| `headers` | The full set of headers as passed by the Git provider. Example: `headers['x-github-event']`retrieves the event type on GitHub. |
310
310
| `.pathChanged` | A suffix function to a string that can be a glob of a path to check if changed. (Supported only for `GitHub` and `GitLab` providers.) |
311
311
| `files` | The list of files that changed in the event (`all`, `added`, `deleted`, `modified`, and `renamed`). Example: `files.all`or `files.deleted`. For pull requests, every file belonging to the pull request will be listed. |
312
+
| Custom params | Any [custom parameters]({{< relref "/docs/guide/customparams" >}}) defined in the Repository CR `spec.params` are available as CEL variables. Example: `enable_ci == "true"`. See [Using custom parameters in CEL matching expressions]({{< relref "/docs/guide/customparams#using-custom-parameters-in-cel-matching-expressions" >}}) for details. |
312
313
313
314
CEL expressions let you do more complex filtering compared to the simple `on-target` annotation matching and enable more advanced scenarios.
0 commit comments