Skip to main content

yw-cicd — Jenkins CI/CD CLI

简洁的 Jenkins 命令行工具,一条命令管理构建部署。支持任意 Jenkins 实例。

安装

pip install yw-jenkins-cli

配置

首次使用需要配置 Jenkins 连接信息(三选一):

方式一:配置文件(推荐)

cat > ~/.jenkins-cli << 'EOF'
JENKINS_URL=https://your-jenkins.example.com
JENKINS_USER=your-username
JENKINS_TOKEN=your-api-token
EOF
chmod 600 ~/.jenkins-cli

方式二:环境变量

export JENKINS_URL="https://your-jenkins.example.com"
export JENKINS_USER="your-username"
export JENKINS_TOKEN="your-api-token"

方式三:一键安装脚本(从源码安装时,自动引导配置)

git clone <repo-url> && cd yw-jenkins-cli && bash setup.sh

API Token 获取方式: 打开 <你的Jenkins>/me/configure → API Token → Add new Token

验证配置:

yw-cicd auth

命令一览

yw-cicd list [FILTER]           # 列出任务(支持正则过滤)
yw-cicd info <任务名>            # 查看任务参数
yw-cicd build <任务名> K=V ...   # 触发构建
yw-cicd status <任务名> [构建号]  # 查看构建状态
yw-cicd history <任务名> [-n N]  # 构建历史
yw-cicd log <任务名> <构建号>     # 查看构建日志
yw-cicd stop <任务名> <构建号>    # 停止构建
yw-cicd auth                    # 验证认证

常见场景

部署项目

# 1. 查看有哪些参数
yw-cicd info my-web-project

# 2. 触发构建(等待完成 + 实时日志)
yw-cicd build my-web-project ENV=test BranchName=master --follow-log

查看最近构建

yw-cicd history my-web-project -n 5

排查构建失败

yw-cicd status my-web-project       # 查看最近状态
yw-cicd log my-web-project 42       # 查看失败日志

搜索任务

yw-cicd list order           # 搜索包含 "order" 的任务
yw-cicd list "web|frontend"  # 正则搜索

Claude Code 集成

项目附带 Claude Code Skill(skill/SKILL.md),安装后可在 Claude Code 中直接对话操作 Jenkins:

# 安装 Skill
mkdir -p ~/.claude/skills/yw-cicd
cp skill/SKILL.md ~/.claude/skills/yw-cicd/

之后直接对 Claude 说:

  • "部署 my-project 到 test 环境"
  • "查看 xxx 最近的构建"
  • "构建失败了,帮我看下日志"

项目结构

yw-jenkins-cli/
├── setup.sh                    # 一键安装脚本
├── pyproject.toml
├── src/jenkins_cli/
│   ├── cli.py                  # CLI 入口(click)
│   ├── client.py               # Jenkins API 客户端(httpx)
│   └── config.py               # 认证配置
├── skill/
│   └── SKILL.md                # Claude Code Skill
└── tests/

Metadata

Release files for yw-jenkins-cli 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for yw-jenkins-cli 0.1.0
File Size Uploaded Provenance
yw_jenkins_cli-0.1.0.tar.gz 12.5 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for yw-jenkins-cli 0.1.0
File Interpreter ABI Platform
yw_jenkins_cli-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 23.1 kB

Release files / yw_jenkins_cli-0.1.0.tar.gz

Download URL yw_jenkins_cli-0.1.0.tar.gz
Size 12.5 kB
Tags Source
SHA-256 checksum
How to use checksums
43c43a41575dd14dc38ae37a310768f2a4ce2ae035b84a536881ecb1f9c5aa58
BLAKE2b-256 checksum
How to use checksums
d12af9d19b9d7fe2ab786409ea99556d66ef47ea6d762646d7aa9a671ce09666
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.3

Release files / yw_jenkins_cli-0.1.0-py3-none-any.whl

Download URL yw_jenkins_cli-0.1.0-py3-none-any.whl
Size 10.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
734e59056be2184ae8db016217c715ce1e46c0a1252d4fddd64225c6e7729231
BLAKE2b-256 checksum
How to use checksums
9ed930180a22b199e5d94b8c68142f79ee23b9ab280a14ee2bf1e40d24c1c7b6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.3

Security for yw-jenkins-cli 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page