python-jcli 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,51 @@
1
+ ---
2
+ name: jcli-plugin
3
+ version: 1.0.0
4
+ description: |
5
+ jcli 插件管理 - 管理 Jenkins 插件的安装、卸载、查看等操作。
6
+ allowed-tools:
7
+ - Bash
8
+ - Read
9
+ ---
10
+
11
+ # jcli-plugin
12
+
13
+ 管理 Jenkins 插件的安装、卸载、查看等操作。
14
+
15
+ ## 前提条件
16
+
17
+ - Python >= 3.10
18
+ - Jenkins 2.x 或更高版本
19
+ - 已安装 jcli:`pip install -e /data/git-project/jcli`
20
+
21
+ ## 命令参考
22
+
23
+ ```bash
24
+ jcli plugin list # 列出已安装插件
25
+ jcli plugin get <name> # 查看插件详情
26
+ jcli plugin install <name> # 安装插件
27
+ jcli plugin install git@4.15.0 # 安装指定版本
28
+ jcli plugin uninstall <name> # 卸载插件
29
+ ```
30
+
31
+ ## 常见用例
32
+
33
+ ### 查看已安装插件
34
+
35
+ ```bash
36
+ # 列出所有插件
37
+ jcli plugin list
38
+
39
+ # 查看特定插件详情
40
+ jcli plugin get git
41
+ ```
42
+
43
+ ### 安装插件
44
+
45
+ ```bash
46
+ # 安装最新版本
47
+ jcli plugin install git
48
+
49
+ # 安装指定版本
50
+ jcli plugin install git@4.15.0
51
+ ```
@@ -0,0 +1,70 @@
1
+ ---
2
+ name: jcli-system
3
+ version: 1.0.0
4
+ description: |
5
+ jcli 系统管理 - 管理 Jenkins 系统信息查看、重启、安静模式等操作。
6
+ allowed-tools:
7
+ - Bash
8
+ - Read
9
+ ---
10
+
11
+ # jcli-system
12
+
13
+ 管理 Jenkins 系统信息查看、重启、安静模式等操作。
14
+
15
+ ## 前提条件
16
+
17
+ - Python >= 3.10
18
+ - Jenkins 2.x 或更高版本
19
+ - 已安装 jcli:`pip install -e /data/git-project/jcli`
20
+
21
+ ## 命令参考
22
+
23
+ ```bash
24
+ jcli system info # 查看系统信息
25
+ jcli system load # 查看系统负载
26
+ jcli system restart # 安全重启 Jenkins
27
+ jcli system quiet-down # 进入安静模式
28
+ jcli system quiet-down --reason "维护" # 带原因的安静模式
29
+ jcli system cancel-quiet-down # 取消安静模式
30
+ jcli system script "println('hello')" # 执行 Groovy 脚本
31
+ ```
32
+
33
+ ## 常见用例
34
+
35
+ ### 查看系统状态
36
+
37
+ ```bash
38
+ # 查看系统版本和统计信息
39
+ jcli system info
40
+
41
+ # 查看队列长度和执行器数量
42
+ jcli system load
43
+ ```
44
+
45
+ ### 维护模式
46
+
47
+ ```bash
48
+ # 进入安静模式(不接受新构建)
49
+ jcli system quiet-down --reason "系统升级"
50
+
51
+ # 取消安静模式
52
+ jcli system cancel-quiet-down
53
+ ```
54
+
55
+ ### 重启 Jenkins
56
+
57
+ ```bash
58
+ # 安全重启(等待当前构建完成)
59
+ jcli system restart
60
+ ```
61
+
62
+ ### 执行 Groovy 脚本
63
+
64
+ ```bash
65
+ # 执行简单的 Groovy 脚本
66
+ jcli system script "println('Hello from jcli')"
67
+
68
+ # 获取所有节点信息
69
+ jcli system script "Jenkins.instance.computers.each { println it.name }"
70
+ ```
@@ -0,0 +1,47 @@
1
+ ---
2
+ name: jcli-view
3
+ version: 1.0.0
4
+ description: |
5
+ jcli 视图管理 - 管理 Jenkins 视图的创建、删除、查看等操作。
6
+ allowed-tools:
7
+ - Bash
8
+ - Read
9
+ ---
10
+
11
+ # jcli-view
12
+
13
+ 管理 Jenkins 视图的创建、删除、查看等操作。
14
+
15
+ ## 前提条件
16
+
17
+ - Python >= 3.10
18
+ - Jenkins 2.x 或更高版本
19
+ - 已安装 jcli:`pip install -e /data/git-project/jcli`
20
+
21
+ ## 命令参考
22
+
23
+ ```bash
24
+ jcli view list # 列出所有视图
25
+ jcli view get <name> # 查看视图详情
26
+ jcli view create <name> -f config.xml # 从 XML 创建视图
27
+ jcli view delete <name> # 删除视图
28
+ ```
29
+
30
+ ## 常见用例
31
+
32
+ ### 查看视图
33
+
34
+ ```bash
35
+ # 列出所有视图
36
+ jcli view list
37
+
38
+ # 查看特定视图详情
39
+ jcli view get my-view
40
+ ```
41
+
42
+ ### 创建视图
43
+
44
+ ```bash
45
+ # 从 XML 配置文件创建视图
46
+ jcli view create my-view -f view-config.xml
47
+ ```
@@ -0,0 +1,311 @@
1
+ Metadata-Version: 2.4
2
+ Name: python-jcli
3
+ Version: 0.1.0
4
+ Summary: Python Jenkins CLI tool
5
+ License: MIT
6
+ Requires-Python: >=3.10
7
+ Description-Content-Type: text/markdown
8
+ Requires-Dist: click>=8.1.0
9
+ Requires-Dist: requests~=2.31.0
10
+ Requires-Dist: pyyaml~=6.0.1
11
+ Requires-Dist: rich>=13.7.1
12
+ Provides-Extra: dev
13
+ Requires-Dist: pytest>=7.0; extra == "dev"
14
+ Requires-Dist: pytest-cov>=4.0; extra == "dev"
15
+ Requires-Dist: responses>=0.23.0; extra == "dev"
16
+
17
+ # jcli
18
+
19
+ A command-line tool for managing Jenkins servers. jcli wraps the Jenkins REST API into readable commands that work the way you'd expect, with table, JSON, and YAML output options.
20
+
21
+ [中文文档](README-zh.md)
22
+
23
+ ## Features
24
+
25
+ - **8 command modules** covering jobs, builds, nodes, plugins, credentials, pipelines, views, and system management
26
+ - **Multiple output formats**: human-readable tables (default, via Rich), JSON, and YAML
27
+ - **Multi-profile support** via `~/.jcli/config.yaml` with environment variable overrides
28
+ - **Automatic CSRF (Crumb) handling** for Jenkins servers with CSRF protection enabled
29
+ - **Built with Click and Rich** for a polished terminal experience
30
+
31
+ ## Requirements
32
+
33
+ - Python 3.10 or later
34
+ - A Jenkins server running Jenkins 2.x or later
35
+
36
+ ## Installation
37
+
38
+ Install from source with pip:
39
+
40
+ ```bash
41
+ pip install .
42
+ ```
43
+
44
+ Or in editable mode for development:
45
+
46
+ ```bash
47
+ pip install -e ".[dev]"
48
+ ```
49
+
50
+ After installation, `jcli` is available as a console script.
51
+
52
+ ## Quick Start
53
+
54
+ ### 1. Configure your Jenkins connection
55
+
56
+ Create a configuration file at `~/.jcli/config.yaml`:
57
+
58
+ ```yaml
59
+ active_profile: default
60
+ profiles:
61
+ default:
62
+ url: https://jenkins.example.com
63
+ username: admin
64
+ api_token: "11abcdef0123456789abcdef0123456789ab"
65
+ description: "Production Jenkins"
66
+ ```
67
+
68
+ If the file doesn't exist, jcli creates it with a template on first run.
69
+
70
+ To generate an API token, go to your Jenkins user page: **Your Username > Configure > API Token > Add new Token**.
71
+
72
+ ### 2. Run your first command
73
+
74
+ ```bash
75
+ jcli job list
76
+ ```
77
+
78
+ If your server is configured correctly, this prints a table of all Jenkins jobs.
79
+
80
+ ## Configuration
81
+
82
+ ### Config file
83
+
84
+ jcli stores profiles in `~/.jcli/config.yaml`. Each profile has four fields:
85
+
86
+ | Field | Description |
87
+ |-------------|----------------------------|
88
+ | `url` | Jenkins server URL |
89
+ | `username` | Jenkins username |
90
+ | `api_token` | Jenkins API token |
91
+ | `description` | Human-readable description |
92
+
93
+ The `active_profile` key selects which profile to use.
94
+
95
+ To add another server profile, edit the file and add a new entry under `profiles`:
96
+
97
+ ```yaml
98
+ active_profile: prod
99
+ profiles:
100
+ prod:
101
+ url: https://jenkins.prod.example.com
102
+ username: admin
103
+ api_token: "..."
104
+ description: "Production"
105
+ staging:
106
+ url: https://jenkins.staging.example.com
107
+ username: admin
108
+ api_token: "..."
109
+ description: "Staging"
110
+ ```
111
+
112
+ ### Environment variables
113
+
114
+ Environment variables override config file values. This is useful in CI pipelines.
115
+
116
+ | Variable | Overrides |
117
+ |-------------------|---------------------|
118
+ | `JCLI_URL` | `url` |
119
+ | `JCLI_USERNAME` | `username` |
120
+ | `JCLI_API_TOKEN` | `api_token` |
121
+ | `JCLI_PROFILE` | `active_profile` |
122
+
123
+ Set `JCLI_PROFILE` to select a profile without editing the config file.
124
+
125
+ ### CLI options
126
+
127
+ Profile and server can also be set with command-line flags:
128
+
129
+ ```bash
130
+ jcli -p staging job list # use the "staging" profile
131
+ jcli -s https://ci.example.com job list # override server URL
132
+ jcli -d job list # enable debug logging
133
+ ```
134
+
135
+ Run `jcli --help` for the full option list.
136
+
137
+ ## Command Reference
138
+
139
+ ### Global options
140
+
141
+ Every command accepts these global flags before the subcommand:
142
+
143
+ ```
144
+ -d, --debug Enable debug output
145
+ -f, --format [table|json|yaml] Output format (default: table)
146
+ -p, --profile TEXT Configuration profile name
147
+ -s, --server TEXT Jenkins server URL
148
+ ```
149
+
150
+ ### job — Manage Jenkins jobs
151
+
152
+ ```
153
+ jcli job list List all jobs
154
+ jcli job get JOB_NAME Show details for a specific job
155
+ jcli job create JOB_NAME -f job-config.xml Create a new job from XML config file
156
+ jcli job config JOB_NAME Print the XML configuration of a job
157
+ jcli job copy SOURCE_JOB NEW_NAME Copy a job to a new name
158
+ jcli job enable JOB_NAME Enable a disabled job
159
+ jcli job disable JOB_NAME Disable a job
160
+ jcli job delete JOB_NAME Delete a job
161
+ ```
162
+
163
+ ### build — Manage Jenkins builds
164
+
165
+ ```
166
+ jcli build list JOB_NAME List recent builds for a job
167
+ jcli build get JOB_NAME BUILD_NUMBER Show details for a specific build
168
+ jcli build trigger JOB_NAME Trigger a new build
169
+ jcli build log JOB_NAME BUILD_NUMBER Show console log for a build
170
+ jcli build stop JOB_NAME BUILD_NUMBER Stop a running build
171
+ jcli build queue Show the current build queue
172
+ ```
173
+
174
+ ### node — Manage Jenkins nodes (agents)
175
+
176
+ ```
177
+ jcli node list List all nodes
178
+ jcli node get NODE_NAME Get details of a specific node
179
+ jcli node delete NODE_NAME Delete a node
180
+ jcli node toggle NODE_NAME --offline Take a node offline
181
+ jcli node toggle NODE_NAME --online Bring a node back online
182
+ ```
183
+
184
+ ### plugin — Manage Jenkins plugins
185
+
186
+ ```
187
+ jcli plugin list List installed plugins
188
+ jcli plugin get PLUGIN_NAME Show details for a single plugin
189
+ jcli plugin install PLUGIN_NAME Install a plugin
190
+ jcli plugin uninstall PLUGIN_NAME Uninstall a plugin
191
+ ```
192
+
193
+ ### credential — Manage Jenkins credentials
194
+
195
+ ```
196
+ jcli credential list List credentials
197
+ jcli credential get CREDENTIAL_NAME Get credential details
198
+ jcli credential create -f cred-config.xml Create a credential from XML config
199
+ jcli credential delete CREDENTIAL_NAME Delete a credential
200
+ ```
201
+
202
+ ### pipeline — Manage Jenkins pipelines
203
+
204
+ ```
205
+ jcli pipeline stages JOB_NAME BUILD_NUMBER List stages for a Pipeline build
206
+ jcli pipeline log JOB_NAME BUILD_NUMBER Get log output for a Pipeline step
207
+ jcli pipeline pending JOB_NAME BUILD_NUMBER Show pending input actions
208
+ jcli pipeline validate -f Jenkinsfile Validate a Jenkinsfile against the server
209
+ ```
210
+
211
+ ### view — Manage Jenkins views
212
+
213
+ ```
214
+ jcli view list List all views
215
+ jcli view get VIEW_NAME Get details for a view
216
+ jcli view create -f view-config.xml Create a view from XML config
217
+ jcli view delete VIEW_NAME Delete a view
218
+ ```
219
+
220
+ ### system — Jenkins system information and management
221
+
222
+ ```
223
+ jcli system info Show system version and stats
224
+ jcli system load Show queue length and executor counts
225
+ jcli system quiet-down Put Jenkins into quiet-down mode
226
+ jcli system cancel-quiet-down Cancel quiet-down mode
227
+ jcli system restart Trigger a safe restart
228
+ jcli system script "println('hello')" Execute a Groovy script on the server
229
+ ```
230
+
231
+ ## Output Formats
232
+
233
+ jcli supports three output formats, selectable with `-f` / `--format`:
234
+
235
+ ```bash
236
+ jcli -f table job list # Rich-formatted table (default)
237
+ jcli -f json job list # JSON output
238
+ jcli -f yaml job list # YAML output
239
+ ```
240
+
241
+ Table mode uses the [Rich](https://github.com/Textualize/rich) library with alternating row colors and auto-width columns. Pipe the output to any file or command as needed.
242
+
243
+ ## Development
244
+
245
+ ### Setup
246
+
247
+ ```bash
248
+ git clone <repo-url> jcli
249
+ cd jcli
250
+ pip install -e ".[dev]"
251
+ ```
252
+
253
+ ### Running tests
254
+
255
+ The test suite uses pytest with the `responses` library for HTTP mocking:
256
+
257
+ ```bash
258
+ pytest
259
+ ```
260
+
261
+ For coverage:
262
+
263
+ ```bash
264
+ pytest --cov=jcli --cov-report=term-missing
265
+ ```
266
+
267
+ ### Project structure
268
+
269
+ ```
270
+ jcli/
271
+ cli.py Main CLI entry point (Click group)
272
+ __init__.py Version
273
+ plugins/ Command modules (one per Jenkins domain)
274
+ job.py
275
+ build.py
276
+ node.py
277
+ plugin.py
278
+ credential.py
279
+ pipeline.py
280
+ view.py
281
+ system.py
282
+ sdk/ Shared libraries
283
+ client.py Jenkins REST API client (HTTP, auth, crumb)
284
+ config.py Configuration management (YAML, env vars)
285
+ output/
286
+ formatter.py Table/JSON/YAML output formatting
287
+ exceptions.py Typed exceptions
288
+ tests/ pytest test suite
289
+ ```
290
+
291
+ ### Dependencies
292
+
293
+ | Package | Purpose |
294
+ |-----------------|-----------------------------|
295
+ | click >= 8.1.0 | CLI framework |
296
+ | requests ~= 2.31 | HTTP client |
297
+ | pyyaml ~= 6.0.1 | YAML config parsing |
298
+ | rich >= 13.7.1 | Terminal formatting (tables) |
299
+ | argcomplete >= 3.3 | Shell tab completion |
300
+
301
+ Dev dependencies (optional `[dev]` extra):
302
+
303
+ | Package | Purpose |
304
+ |-----------------|-----------------------------|
305
+ | pytest >= 7.0 | Test runner |
306
+ | pytest-cov >= 4.0 | Coverage reporting |
307
+ | responses >= 0.23 | HTTP response mocking |
308
+
309
+ ## License
310
+
311
+ MIT
@@ -0,0 +1,44 @@
1
+ jcli/__init__.py,sha256=kUR5RAFc7HCeiqdlX36dZOHkUI5wI6V_43RpEcD8b-0,22
2
+ jcli/__main__.py,sha256=ARL8XYr45T4pIf0gnyCCbK8uljcn1LF7TKcFapxHt_k,34
3
+ jcli/cli.py,sha256=Ep6OFwyx4eVdbMbVcXrebPboMQuXarkYuxTILTst3eM,2135
4
+ jcli/cli_helpers.py,sha256=8GsvEwmaqS8p9Rpx7d_b3_i_Pwag8zsJNNbunxgNXS0,1831
5
+ jcli/plugins/__init__.py,sha256=I6vTpfYO3gIwHoNu5V-sOIdpT_g-bAy4RXR3TW3-k1U,1054
6
+ jcli/plugins/build.py,sha256=60F0UPMFy_eZznBeAIM0XwCcQ3pAuJJjacGaCXxOlcI,6032
7
+ jcli/plugins/config.py,sha256=OEl8X5zrYIBRHhBx1s6GokqBZ2yKRLYgMOVJjjbZgho,8302
8
+ jcli/plugins/credential.py,sha256=ZLdKXoU1ZResv0FqWOH6XWNfb5iSi1rg3dFX1VZPd10,6415
9
+ jcli/plugins/job.py,sha256=dq5jbAn8ZjtYNqJlo7u-0iORubMdZMB2sj4GVK01xoU,12872
10
+ jcli/plugins/node.py,sha256=nwUDYvev9R_BOoYHVmNvNp3vhrmZAXVFN2z_-F_iO7I,4776
11
+ jcli/plugins/pipeline.py,sha256=vTtLk0tPiMSwy2CsCEmtQMhbt9baFoxAqGCSyHtOmOc,3049
12
+ jcli/plugins/plugin.py,sha256=0LMaPjr5jpZokOLENt0rDi_Klk4JYcw8uUzZUceDYvk,4713
13
+ jcli/plugins/skills.py,sha256=WAJJN9_r9kgS2FCjoZeeQZhTrU9ZF0zUu3wpLwniHs4,13177
14
+ jcli/plugins/system.py,sha256=2ojwBOsaiuNKmuiTLvU6GpLeSI3-kccy1QjpHuX_8vE,4938
15
+ jcli/plugins/view.py,sha256=eH7pCe7Tw1rC4kVBZDxHqVd3ZrXYLlVxNGPjWvhgw8Q,4475
16
+ jcli/sdk/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
+ jcli/sdk/build.py,sha256=xNMPOCL-RUBQo7OJDuaIZ-DtnxN15kZbyO_insEiklM,5309
18
+ jcli/sdk/client.py,sha256=hnBZcS82ziPyHepPWq7femUqQppw8QCtwbdMrWYVrxc,8723
19
+ jcli/sdk/config.py,sha256=fSBTWqE0i8jpzmtGfo2M-Ln2Y5eQRQD0StS76glyCsI,6992
20
+ jcli/sdk/credential.py,sha256=ayasSZjfn62Z1E6Rc15mqeqN0LyQ1wzO2OBsmlXY7Kk,4009
21
+ jcli/sdk/exceptions.py,sha256=zv5oYOr_t0rma4lVudLp3gLdL5idSzlKGc7g2MowcL0,1737
22
+ jcli/sdk/job.py,sha256=SLuCWdmKm9Y-hh1-TGGNCtELbFen8o6kt4nn4q1BqGg,4877
23
+ jcli/sdk/job_templates.py,sha256=IDQFvlLjMxDP1sLfZUHSo6karjVKu9rsb3dZlMmXqpM,4021
24
+ jcli/sdk/node.py,sha256=N7VTTxXhZKtik2Pn5tJMLoVkqz7iI5BDc-4o8u_c4Ig,4032
25
+ jcli/sdk/pipeline.py,sha256=NLUNC8thSfHWc9_hf5N6wpeeHNlAFLj74Crb5HZmPG8,3515
26
+ jcli/sdk/plugin.py,sha256=kKmxVPgV66sEUAc9J85-E8edY3qpcTw1M4FY_7OUqW8,4671
27
+ jcli/sdk/system.py,sha256=L5PHlrjs-5_PFFOQ9IBA-vMwgQyqq33TfJidTcs0VSQ,6022
28
+ jcli/sdk/view.py,sha256=5Poo50l3eY9ivef3hs0CyL-K39qDk39XQuX7gEHHRlA,2300
29
+ jcli/sdk/output/__init__.py,sha256=Rt0F77oq24tqHvTDV4HyWKAjDtOyPOh9m7ucFy7B77s,70
30
+ jcli/sdk/output/formatter.py,sha256=OUjQxeD-2iSNncuuRaLa01qLi899ux3F39KNkc8ik2Q,3876
31
+ jcli/skills/jcli/SKILL.md,sha256=DM471dAnNguIzQKHMEBG3u6YafEzh9j3MesR8facQNQ,2384
32
+ jcli/skills/jcli/config/SKILL.md,sha256=AHGfoitHRNPI0PyfKNrmOAG-k55RQOUacrDPfHiVDrI,1728
33
+ jcli/skills/jcli/credential/SKILL.md,sha256=vOo2HWoVwv1IeQqALe7nOhwZ-qp4uLabanB4L8y14h8,943
34
+ jcli/skills/jcli/job/SKILL.md,sha256=x8ytgCuHbwG1sspwLhzsd06AW4nw5M42ioHFqJi8yd8,1322
35
+ jcli/skills/jcli/node/SKILL.md,sha256=E_r4aYjIr213qiTS6KGz08tV08hdsc8tlIzKZucrsts,1034
36
+ jcli/skills/jcli/pipeline/SKILL.md,sha256=0cffcYTy-FzlqffosR-adSR7zne3Yfq08TEn1Yd6eCY,1177
37
+ jcli/skills/jcli/plugin/SKILL.md,sha256=ybzQacz2-k0H9sTm4CwAEG40unT-Ndx1ngFrSv19KwA,986
38
+ jcli/skills/jcli/system/SKILL.md,sha256=d2EkJSQnjaZFQ2MHWniHPxpHLGtZ9iDVy3jC2zev4zw,1538
39
+ jcli/skills/jcli/view/SKILL.md,sha256=e-huIcHxr-A3tKFUkjQIV6mT2O9RKlSmEJ6HJ9NylyI,895
40
+ python_jcli-0.1.0.dist-info/METADATA,sha256=1FUFhHyJ7BY_SC8xws-JjdaXFSBXsuQellAgHE90OWk,9276
41
+ python_jcli-0.1.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
42
+ python_jcli-0.1.0.dist-info/entry_points.txt,sha256=g-Gb8voGH3Ru4NEoCUMJXJiMZMapdAfYi6Xt1phyFi4,39
43
+ python_jcli-0.1.0.dist-info/top_level.txt,sha256=WFqrbWSEfhvQfbN2m-_Wi5KKCwv1_23LhzPUqo7AdQc,5
44
+ python_jcli-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (82.0.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ jcli = jcli.cli:main
@@ -0,0 +1 @@
1
+ jcli