jk
Fast, API-driven Jenkins CLI for inspecting builds and failures. Built with Bun, TypeScript, and Effect.
Inspired by prior CLI work done by Evan Battaglia.
Quick Start
bun install -g @aaronshaf/jk
jk setup
jk failures https://jenkins.example.com/job/MyProject/123/
jk console https://jenkins.example.com/blue/.../pipeline/534
jk failures --smart --xml https://jenkins.example.com/job/MyProject/123/ | pbcopy
Installation
Prerequisites: Bun runtime v1.0.0 or later
curl -fsSL https://bun.sh/install | bash
bun install -g @aaronshaf/jk
jk setup
Setup options:
- Direct storage: Credentials saved to ~/.config/jk/config.json(file permissions: 600)
- Environment variables: Use JENKINS_USERNAMEandJENKINS_API_TOKEN(more secure)
Commands
Inspect Builds
jk build pipelines/MyProject/main/123
jk build https://jenkins.example.com/job/MyProject/123/
Inspect Failures
jk failures pipelines/MyProject/main/456
echo "456" | jk failures
jk failures --shallow pipelines/MyProject/main/456
jk failures --full pipelines/MyProject/main/456
jk failures --smart --xml pipelines/MyProject/main/456
jk failures --tail 200 --xml pipelines/MyProject/main/456
jk failures --grep "ERROR|FATAL" --xml pipelines/MyProject/main/456
Console Output
jk console pipelines/MyProject/main/456 node-123
jk console https://jenkins.example.com/blue/.../pipelines/MyProject/main/detail/main/154928/pipeline/534
echo "https://jenkins.example.com/blue/.../pipeline/534" | jk console
jk console <url> | grep ERROR
jk console <url> | less
Pro tip: Run jk failures to see all failed nodes with URLs, then copy-paste any URL directly into jk console.
Key Features
XML Output for LLMs
jk build --xml pipelines/MyProject/main/123
jk failures --xml pipelines/MyProject/main/456
XML output is optimized for consumption by LLMs (Claude, etc.) and provides structured, easily parseable build data.
Console output filtering (avoids context window explosions):
- --smart: Last 100 lines + all error/fail/exception lines (recommended for LLMs)
- --tail <n>: Last N lines only
- --grep <pattern>: Lines matching regex pattern
- --full: Full console output (can be very large)
All filters apply per failed node - when using --recursive, each sub-build failure is filtered individually.
Example LLM workflow:
jk failures --smart --xml <build> | pbcopy
Flexible Locator Formats
jk accepts multiple formats for identifying builds:
Build locators:
- Full Jenkins URL: https://jenkins.example.com/job/MyProject/123/
- Pipeline URL: https://jenkins.example.com/.../pipelines/MyProject/runs/123
- Pipeline path: pipelines/MyProject/main/123
- Pipeline with runs: pipelines/MyProject/main/runs/123
Node URLs (for jk console):
- Blue Ocean node URL: https://jenkins.example.com/blue/.../pipelines/Project/Branch/detail/Branch/BuildNumber/pipeline/NodeId
- Traditional: <locator> <node-id>(still supported)
Recursive Failure Inspection (Default)
By default, jk failures recursively traverses sub-builds to find root causes:
jk failures pipelines/MyProject/main/456
jk failures --recursive pipelines/MyProject/main/456
jk failures --shallow pipelines/MyProject/main/456
When a parent build triggers sub-builds (e.g., MyProject/main → test-suites/JS), the tool automatically gathers failures from all levels. This ensures you see the actual test failures instead of just "wrapper failed" messages.
Combine with filtering for optimal LLM analysis:
jk failures --tail 200 --xml pipelines/MyProject/main/456
Documentation
Upgrading
To upgrade jk to the latest version:
bun update -g @aaronshaf/jk
After upgrading, you may want to review new configuration options:
jk setup  
License
MIT