Jenkins CLI

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 json or -o yaml to 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_code is omitted when no upstream HTTP status is available.
  • Raw commands such as job config and build log emit XML or log text. Write commands may emit informational text unless --quiet is set.
  • A non-zero exit code signals failure.

Safety flags

FlagEnvironmentEffect
--read-onlyJENKINS_READ_ONLY=trueBlocks commands marked as mutating
--no-inputJENKINS_NO_INPUT=1Disables interactive prompts and requires explicit confirmation flags
--quietJENKINS_QUIET=1Suppresses 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 json

Destructive 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/.