Agents
Structured output, safety flags, and non-interactive Jenkins CLI usage.
Jenkins CLI is designed to be driven by coding agents as well as humans. It works with Claude Code, OpenAI Codex, Cursor, or any coding agent harness that can run shell commands.
The output contract
- Add
-o jsonor-o yamlto structured read commands. - Successful command output is written to stdout; errors are written to stderr.
- In JSON mode, failures are structured as
{"error":"...","status_code":403};status_codeis omitted when no upstream HTTP status is available. - Raw commands such as
job configandbuild logemit XML or log text. Write commands may emit informational text unless--quietis set. - A non-zero exit code signals failure.
Safety flags
| Flag | Environment | Effect |
|---|---|---|
--read-only | JENKINS_READ_ONLY=true | Blocks commands marked as mutating |
--no-input | JENKINS_NO_INPUT=1 | Disables interactive prompts and requires explicit confirmation flags |
--quiet | JENKINS_QUIET=1 | Suppresses informational command output |
# Safe, non-interactive reads for an agent
JENKINS_READ_ONLY=true JENKINS_NO_INPUT=1 jenkins job list --recursive -o json--read-only blocks CLI commands annotated as writes. It is a guardrail, not a
replacement for Jenkins RBAC; use a least-privilege Jenkins account as well.
Configuration via environment
No login step or config-file write is needed:
export JENKINS_URL=https://jenkins.example.com
export JENKINS_USER=automation
export JENKINS_TOKEN=11xxxxxxxxxxxxxxxxxx
export JENKINS_NO_INPUT=1
jenkins status -o jsonDestructive commands require --confirm. Create and delete workflows also offer
idempotency flags where supported, including --if-not-exists and --if-exists.
Use --from-file - to pipe job XML, credential XML, Jenkinsfiles, or Groovy
scripts into commands that accept --from-file.
Agent skill
A ready-to-use skill lives at
jenkins/SKILL.md,
with the expanded command reference under jenkins/references/.