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
This commit introduces a new command `tkn pac cel` that allows
users to interactively evaluate CEL (Common Expression Language)
expressions. The command is designed to help users test and debug
CEL expressions, which are commonly used in Pipelines-as-Code.
Key features include:
- Interactive and non-interactive modes.
- Support for webhook payloads and headers.
- Provider auto-detection (GitHub, GitLab, Bitbucket Cloud,
Bitbucket Data Center, Gitea).
- Direct access to variables as per PAC documentation.
- Cross-platform history with readline experience.
- Comprehensive help and example expressions.
Signed-off-by: Chmouel Boudjnah <[email protected]>
feat: Support gosmee-generated shell scripts for headers
- Allow the CLI to parse headers from gosmee scripts.
- Add support for JSON, plain text and gosmee scripts header formats.
- Update documentation to reflect the changes in the header file formats.
- Add tests to validate the script and header parsing.
Signed-off-by: Chmouel Boudjnah <[email protected]>
Copy file name to clipboardExpand all lines: docs/content/docs/guide/cli.md
+105Lines changed: 105 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -409,6 +409,111 @@ You can specify a different directory than the current one by using the -d/--dir
409
409
410
410
{{< /details >}}
411
411
412
+
{{< details "tkn pac cel" >}}
413
+
414
+
### CEL Expression Evaluator
415
+
416
+
`tkn pac cel` — Evaluate CEL (Common Expression Language) expressions interactively with webhook payloads.
417
+
418
+
This command allows you to test and debug CEL expressions as they would be evaluated by Pipelines-as-Code, using real webhook payloads and headers. It supports interactive and non-interactive modes, provider auto-detection, and persistent history.
419
+
420
+
To be able to have the CEL evaluator working, you need to have the payload and the headers available in a file. The best way to do this is to go to the webhook configuration on your git provider and copy the payload and headers to different files.
421
+
422
+
The payload is the JSON content of the webhook request, The headers file supports multiple formats:
423
+
424
+
1.**Plain HTTP headers format** (as shown above)
425
+
2.**JSON format**:
426
+
427
+
```json
428
+
{
429
+
"X-GitHub-Event": "pull_request",
430
+
"Content-Type": "application/json",
431
+
"User-Agent": "GitHub-Hookshot/2d5e4d4"
432
+
}
433
+
```
434
+
435
+
3.**Gosmee-generated shell scripts**: The command automatically detects and parses shell scripts generated by [gosmee](https://github.com/chmouel/gosmee) which are generated when using the `--save` feature, extracting headers from curl commands with `-H` flags:
436
+
437
+
```bash
438
+
#!/usr/bin/env bash
439
+
curl -X POST "http://localhost:8080/" \
440
+
-H "X-GitHub-Event: pull_request" \
441
+
-H "Content-Type: application/json" \
442
+
-H "User-Agent: GitHub-Hookshot/2d5e4d4" \
443
+
-d @payload.json
444
+
```
445
+
446
+
#### Usage
447
+
448
+
```shell
449
+
tkn pac cel -b <body.json> -H <headers.txt>
450
+
```
451
+
452
+
*`-b, --body`: Path to JSON body file (webhook payload)
453
+
*`-H, --headers`: Path to headers file (plain text, JSON, or gosmee script)
0 commit comments