| name | jk |
| version | 0.0.34 |
| description | Jenkins CLI for controllers. Use when users need to manage jobs, pipelines, config.xml, runs, logs, artifacts, credentials, nodes, or queues in Jenkins. Triggers include "jenkins", "jk", "pipeline", "build", "job create", "job config", "config.xml", "run logs", "jenkins credentials", "jenkins node". |
| metadata | {"short-description":"Jenkins CLI for jobs, config, pipelines, runs","compatibility":"claude-code, codex-cli"} |
Jenkins CLI (jk)
jk is a GitHub CLI–style interface for Jenkins controllers. It provides modern, scriptable workflows for developers and operators.
Dependency Check
Before executing any jk command, verify the CLI is installed:
jk --version
For jk job create, jk job config, jk job configure, and jk job scan, use jk 0.0.29 or newer.
If the command fails or jk is not found, install it using one of these methods:
| Platform | Command |
|---|
| macOS/Linux | brew install avivsinai/tap/jk |
| Windows | scoop bucket add avivsinai https://github.com/avivsinai/scoop-bucket && scoop install jk |
| Go | go install github.com/avivsinai/jenkins-cli/cmd/jk@latest |
| Binary | Download from GitHub Releases |
Only proceed with jk commands after confirming installation succeeds.
Authentication
jk auth login https://jenkins.example.com --username alice --token <API_TOKEN>
jk auth login https://jenkins.example.com --username alice@example.com --token <JENKINS_API_TOKEN>
jk auth login https://jenkins.example.com --name prod --username alice --token <TOKEN>
jk auth login https://jenkins.example.com --username alice --token <TOKEN> --insecure
jk auth login https://jenkins.example.com --username alice --token <TOKEN> --ca-file /path/to/ca.pem
jk auth status
jk auth logout
jk auth logout prod
Options for auth login:
--name — Context name (defaults to hostname)
--username — Jenkins user ID (Google/SSO users: usually your email)
--token — Jenkins API token
--insecure — Skip TLS verification
--proxy — Proxy URL
--ca-file — Custom CA bundle
--set-active — Set as active context (default: true)
--allow-insecure-store — Allow encrypted file fallback
For Google OAuth, OpenID Connect, Okta, Azure AD, or other browser SSO security realms, first sign in to Jenkins in the browser and create a Jenkins API token from /me/configure. Use that Jenkins API token with --token; do not use a Google/OIDC access token.
Contexts
Contexts store controller URLs and credentials for easy switching:
jk context ls
jk context use prod-jenkins
jk context rm staging
Environment: JK_CONTEXT overrides active context.
Quick Command Reference
| Task | Command |
|---|
| Search jobs | jk search --job-glob '*deploy*' |
| List jobs | jk job ls |
| View job | jk job view team/app |
| Create multibranch job | jk job create auth-relay --folder platform/services --repo-owner playg --repository repo |
| Fetch job config | jk job config platform/services/auth-relay |
| Patch Jenkinsfile path | jk job configure platform/services/auth-relay --script-path services/auth-relay/Jenkinsfile |
| Rescan multibranch job | jk job scan platform/services/auth-relay |
| List runs | jk run ls team/app |
| Start run | jk run start team/app -p KEY=value |
| View run | jk run view team/app 128 |
| Follow logs | jk run start team/app --follow |
| Stream logs | jk log team/app 128 --follow |
| Download artifacts | jk artifact download team/app 128 |
| Test report | jk test report team/app 128 |
| List credentials | jk cred ls |
| List nodes | jk node ls |
| View queue | jk queue ls |
| List plugins | jk plugin ls |
Job Discovery
jk search --job-glob '*deploy*' --limit 10
jk search --folder team/services --job-glob '*api*'
jk search --job-glob '*' --filter result=FAILURE --since 7d
jk search --job-glob '*/deploy-*' --filter param.ENV=production
Job Operations
jk job ls
jk job ls team/app
jk job ls --folder team/app
jk job view team/app/pipeline
jk job create auth-relay \
--folder platform/services \
--repo-owner playg \
--repository taboola-sales-skills \
--script-path services/auth-relay/Jenkinsfile \
--credentials bitbucket-ro \
--branch-strategy all
jk job config platform/services/auth-relay
jk job configure platform/services/auth-relay --file auth-relay.config.xml
cat auth-relay.config.xml | jk job configure platform/services/auth-relay --stdin
jk job configure platform/services/auth-relay --script-path services/auth-relay/Jenkinsfile
jk job scan platform/services/auth-relay
Run Management
Listing Runs
jk run ls team/app/pipeline
jk run ls team/app/pipeline --limit 50
jk run ls team/app/pipeline --filter result=SUCCESS
jk run ls team/app/pipeline --filter result=FAILURE --since 7d
jk run ls team/app/pipeline --filter param.ENV=staging
jk run ls team/app/pipeline --include-queued
jk run ls team/app/pipeline --group-by param.ENV --agg last
jk run ls team/app/pipeline --json --with-meta
jk run ls team/app/pipeline --cursor <cursor-from-previous>
Starting Runs
jk run start team/app/pipeline
jk run start team/app/pipeline -p BRANCH=main -p ENV=staging
jk run start team/app/pipeline --follow
jk run start team/app/pipeline --wait --timeout 10m
jk run start team/app/pipeline --follow --result
jk run start deploy --fuzzy
Viewing Runs
jk run view team/app/pipeline 128
jk run view team/app/pipeline 128 --result
jk run view team/app/pipeline 128 --exit-status
jk run view team/app/pipeline 128 --wait --timeout 5m
jk run view team/app/pipeline 128 --summary
Other Run Commands
jk run params team/app/pipeline
jk run cancel team/app/pipeline 128
jk run cancel team/app/pipeline 128 --mode term
jk run cancel team/app/pipeline 128 --mode kill
jk run rerun team/app/pipeline 128
jk run rerun team/app/pipeline 128 --follow
Logs
jk log team/app/pipeline 128
jk log team/app/pipeline 128 --follow
jk log team/app/pipeline 128 --follow --interval 2s
jk log team/app/pipeline 128 --plain
Artifacts
jk artifact ls team/app/pipeline 128
jk artifact download team/app/pipeline 128
jk artifact download team/app/pipeline 128 --pattern "**/*.jar"
jk artifact download team/app/pipeline 128 -p "reports/**/*.xml"
jk artifact download team/app/pipeline 128 -o ./artifacts/
jk artifact download team/app/pipeline 128 -p "*.log" --allow-empty
Test Results
jk test report team/app/pipeline 128
jk test report team/app/pipeline 128 --json
Credentials
jk cred ls
jk cred ls --scope folder --folder team/app
jk cred create-secret --id my-secret --secret "value"
jk cred create-secret --id my-secret --secret "value" --description "API key"
echo "secret-value" | jk cred create-secret --id my-secret --from-stdin
jk cred create-secret --id my-secret --secret "value" --scope folder --folder team/app
jk cred rm my-secret
Node Management
jk node ls
jk node cordon agent-01
jk node cordon agent-01 --message "Maintenance"
jk node uncordon agent-01
jk node rm agent-01
Queue Management
jk queue ls
jk queue cancel <item-id>
Plugin Management
jk plugin ls
jk plugin install docker-workflow
jk plugin install docker-workflow --yes
jk plugin install docker-workflow@1.26
jk plugin enable docker-workflow
jk plugin disable docker-workflow
Output Modes
All commands support structured output:
jk run ls team/app --json
jk run ls team/app --yaml
jk run ls team/app --json --jq '.items[0].number'
jk run ls team/app --json --template '{{range .items}}{{.number}}{{end}}'
jk run start team/app --quiet
Global Options
-c, --context <name> — Use specific context
--json — JSON output
--yaml — YAML output
--format json|yaml — Output format
--jq <expr> — Filter JSON with jq expression
-t, --template <tmpl> — Format with Go template
-q, --quiet — Suppress non-essential output
Environment Variables
JK_CONTEXT — Override active context
JK_QUIET — Equivalent to --quiet (any value enables)
Exit Codes
| Code | Meaning |
|---|
| 0 | Success |
| 1 | General error |
| 2 | Validation error |
| 3 | Not found |
| 4 | Authentication failure |
| 5 | Permission denied |
| 6 | Connectivity failure |
| 7 | Timeout |
| 8 | Feature unsupported |
With --follow or --wait, build results use additional codes:
| Code | Result |
|---|
| 0 | SUCCESS |
| 10 | UNSTABLE |
| 11 | FAILURE |
| 12 | ABORTED |
| 13 | NOT_BUILT |
| 14 | RUNNING |
References
- artifact — Work with run artifacts
- auth — Authenticate with Jenkins instances
- context — Manage Jenkins contexts
- cred — Manage Jenkins credentials
- job — Manage Jenkins jobs and pipelines
- node — Inspect and manage Jenkins nodes
- plugin — Inspect and manage Jenkins plugins
- queue — Inspect the build queue
- run — Interact with job runs
- test — Inspect test results
- other — log, search, version