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/
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
yw_jenkins_cli-0.1.0.tar.gz
(12.5 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file yw_jenkins_cli-0.1.0.tar.gz.
File metadata
- Download URL: yw_jenkins_cli-0.1.0.tar.gz
- Upload date:
- Size: 12.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
43c43a41575dd14dc38ae37a310768f2a4ce2ae035b84a536881ecb1f9c5aa58
|
|
| MD5 |
fea83d9fb779e8553e19157df17f6beb
|
|
| BLAKE2b-256 |
d12af9d19b9d7fe2ab786409ea99556d66ef47ea6d762646d7aa9a671ce09666
|
File details
Details for the file yw_jenkins_cli-0.1.0-py3-none-any.whl.
File metadata
- Download URL: yw_jenkins_cli-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
734e59056be2184ae8db016217c715ce1e46c0a1252d4fddd64225c6e7729231
|
|
| MD5 |
5f4b6d7536ff25954e0665cbe18f2337
|
|
| BLAKE2b-256 |
9ed930180a22b199e5d94b8c68142f79ee23b9ab280a14ee2bf1e40d24c1c7b6
|