jenkee 0.2.1__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.
Files changed (66) hide show
  1. jenkee-0.2.1.dist-info/METADATA +199 -0
  2. jenkee-0.2.1.dist-info/RECORD +66 -0
  3. jenkee-0.2.1.dist-info/WHEEL +5 -0
  4. jenkee-0.2.1.dist-info/entry_points.txt +3 -0
  5. jenkee-0.2.1.dist-info/top_level.txt +1 -0
  6. jenkins_tools/__init__.py +3 -0
  7. jenkins_tools/cli.py +120 -0
  8. jenkins_tools/commands/__init__.py +51 -0
  9. jenkins_tools/commands/add_job_to_view.py +57 -0
  10. jenkins_tools/commands/auth.py +67 -0
  11. jenkins_tools/commands/build.py +83 -0
  12. jenkins_tools/commands/console.py +53 -0
  13. jenkins_tools/commands/copy_job.py +53 -0
  14. jenkins_tools/commands/create_job.py +67 -0
  15. jenkins_tools/commands/delete_builds.py +65 -0
  16. jenkins_tools/commands/delete_job.py +70 -0
  17. jenkins_tools/commands/describe_credentials.py +163 -0
  18. jenkins_tools/commands/disable_job.py +70 -0
  19. jenkins_tools/commands/enable_job.py +70 -0
  20. jenkins_tools/commands/get_job.py +49 -0
  21. jenkins_tools/commands/groovy.py +68 -0
  22. jenkins_tools/commands/help.py +225 -0
  23. jenkins_tools/commands/job_diff.py +75 -0
  24. jenkins_tools/commands/job_status.py +125 -0
  25. jenkins_tools/commands/list_builds.py +71 -0
  26. jenkins_tools/commands/list_credentials.py +159 -0
  27. jenkins_tools/commands/list_jobs.py +70 -0
  28. jenkins_tools/commands/list_views.py +34 -0
  29. jenkins_tools/commands/prompt.py +408 -0
  30. jenkins_tools/commands/stop_builds.py +65 -0
  31. jenkins_tools/commands/update_job.py +65 -0
  32. jenkins_tools/core.py +121 -0
  33. jenkins_tools/credential_describers/__init__.py +38 -0
  34. jenkins_tools/credential_describers/azure_credentials.py +42 -0
  35. jenkins_tools/credential_describers/azure_storage_credentials.py +41 -0
  36. jenkins_tools/credential_describers/base.py +93 -0
  37. jenkins_tools/credential_describers/browserstack_credentials.py +34 -0
  38. jenkins_tools/credential_describers/file_credentials.py +76 -0
  39. jenkins_tools/credential_describers/gcp_credentials.py +85 -0
  40. jenkins_tools/credential_describers/gitlab_token_credentials.py +30 -0
  41. jenkins_tools/credential_describers/ssh_key_credentials.py +84 -0
  42. jenkins_tools/credential_describers/string_credentials.py +61 -0
  43. jenkins_tools/credential_describers/username_password_credentials.py +68 -0
  44. jenkins_tools/docs/examples/add-job-to-view.md +166 -0
  45. jenkins_tools/docs/examples/auth.md +129 -0
  46. jenkins_tools/docs/examples/build.md +272 -0
  47. jenkins_tools/docs/examples/console.md +191 -0
  48. jenkins_tools/docs/examples/copy-job.md +265 -0
  49. jenkins_tools/docs/examples/create-job.md +343 -0
  50. jenkins_tools/docs/examples/delete-builds.md +350 -0
  51. jenkins_tools/docs/examples/delete-job.md +344 -0
  52. jenkins_tools/docs/examples/describe-credentials.md +377 -0
  53. jenkins_tools/docs/examples/disable-job.md +230 -0
  54. jenkins_tools/docs/examples/enable-job.md +271 -0
  55. jenkins_tools/docs/examples/get-job.md +204 -0
  56. jenkins_tools/docs/examples/groovy.md +158 -0
  57. jenkins_tools/docs/examples/help.md +144 -0
  58. jenkins_tools/docs/examples/job-diff.md +300 -0
  59. jenkins_tools/docs/examples/job-status.md +236 -0
  60. jenkins_tools/docs/examples/list-builds.md +134 -0
  61. jenkins_tools/docs/examples/list-credentials.md +463 -0
  62. jenkins_tools/docs/examples/list-jobs.md +180 -0
  63. jenkins_tools/docs/examples/list-views.md +111 -0
  64. jenkins_tools/docs/examples/prompt.md +375 -0
  65. jenkins_tools/docs/examples/stop-builds.md +335 -0
  66. jenkins_tools/docs/examples/update-job.md +422 -0
@@ -0,0 +1,199 @@
1
+ Metadata-Version: 2.4
2
+ Name: jenkee
3
+ Version: 0.2.1
4
+ Summary: Jenkins CLI Helper Tools
5
+ Author: Jenkins Studio Team
6
+ License: MIT
7
+ Classifier: Development Status :: 3 - Alpha
8
+ Classifier: Intended Audience :: Developers
9
+ Classifier: Topic :: Software Development :: Build Tools
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3.10
12
+ Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Requires-Python: >=3.10
15
+ Description-Content-Type: text/markdown
16
+ Requires-Dist: python-dotenv>=1.0.0
17
+ Provides-Extra: dev
18
+ Requires-Dist: pytest>=7.0; extra == "dev"
19
+ Requires-Dist: pytest-cov>=4.0; extra == "dev"
20
+ Requires-Dist: testcontainers>=3.7.1; extra == "dev"
21
+ Requires-Dist: black>=22.0; extra == "dev"
22
+ Requires-Dist: flake8>=5.0; extra == "dev"
23
+ Requires-Dist: mypy>=0.990; extra == "dev"
24
+ Provides-Extra: release
25
+ Requires-Dist: build>=1.0.0; extra == "release"
26
+ Requires-Dist: twine>=4.0.0; extra == "release"
27
+
28
+ # Jenkins Inspector
29
+
30
+ Jenkins CLI 工具,提供命令列介面來管理和探索 Jenkins jobs、builds、credentials 等資源。
31
+
32
+ 主要 CLI 命令為 `jenkee`(保留 `jks` 作為相容 alias)。
33
+
34
+ ## 安裝
35
+
36
+ ### 使用 pipx 安裝(推薦)
37
+
38
+ ```bash
39
+ pipx install git+https://github.com/qrtt1/jenkins-inspector
40
+ ```
41
+
42
+ ### 開發模式安裝
43
+
44
+ 如果想要參與開發或修改程式碼:
45
+
46
+ ```bash
47
+ # Clone repository
48
+ git clone https://github.com/qrtt1/jenkins-inspector
49
+ cd jenkins-inspector
50
+
51
+ # 啟用虛擬環境
52
+ source venv/bin/activate
53
+
54
+ # 以 editable 模式安裝
55
+ pip install -e .
56
+ ```
57
+
58
+ ## 與 AI Agent 的互動
59
+
60
+ 如果你不熟悉 Jenkins Inspector 的使用方式,或想讓 AI agent 協助你完成 Jenkins 相關任務,可以使用 `prompt` 命令:
61
+
62
+ ```bash
63
+ jenkee prompt
64
+ ```
65
+
66
+ 這個命令會輸出專為 AI agent 設計的使用指引,包含:
67
+ - Jenkins Inspector 的功能說明
68
+ - 各命令的使用方式與情境
69
+ - AI agent 操作建議與最佳實踐
70
+
71
+ 你可以將輸出的內容複製給你的 AI assistant(如 ChatGPT、Claude),讓它更了解如何協助你使用 Jenkins Inspector。
72
+
73
+ ### 自訂 AI Agent Prompt
74
+
75
+ 如果需要自訂 prompt 內容(例如:加入團隊特定的工作流程、命名規範等),可以透過以下方式:
76
+
77
+ **方式 1:使用預設位置**
78
+
79
+ ```bash
80
+ # 建立自訂 prompt
81
+ cat > ~/.jenkins-inspector/prompt.md << 'EOF'
82
+ # 我的使用指引
83
+
84
+ 自訂的 prompt 內容...
85
+ EOF
86
+ ```
87
+
88
+ **方式 2:使用環境變數指定檔案位置**
89
+
90
+ ```bash
91
+ # 設定環境變數
92
+ export JENKINS_INSPECTOR_PROMPT_FILE=/path/to/my-prompt.md
93
+
94
+ # 執行 prompt 命令
95
+ jenkee prompt
96
+ ```
97
+
98
+ 環境變數 `JENKINS_INSPECTOR_PROMPT_FILE` 的優先級高於預設位置。
99
+
100
+ **暫時忽略自訂 prompt**
101
+
102
+ 如果需要暫時使用預設 prompt 而不刪除自訂檔案:
103
+
104
+ ```bash
105
+ # 使用 --ignore-override flag
106
+ jenkee prompt --ignore-override
107
+ ```
108
+
109
+ 詳細說明請參考 [docs/examples/prompt.md](docs/examples/prompt.md)。
110
+
111
+ ## 設定認證
112
+
113
+ ```bash
114
+ # 建立設定檔目錄
115
+ mkdir -p ~/.jenkins-inspector
116
+
117
+ # 編輯 .env 檔案
118
+ cat > ~/.jenkins-inspector/.env << EOF
119
+ JENKINS_URL=http://your-jenkins-server:8080/
120
+ JENKINS_USER_ID=your_email@example.com
121
+ JENKINS_API_TOKEN=your_api_token
122
+ EOF
123
+
124
+ # 驗證認證
125
+ jenkee auth
126
+ ```
127
+
128
+ ## 可用命令
129
+
130
+ ### 一般命令
131
+
132
+ | 命令 | 說明 | 範例 |
133
+ |------|------|------|
134
+ | `help` | 顯示命令說明 | `jenkee help [command]` |
135
+ | `prompt` | 顯示 AI agent 使用指引 | `jenkee prompt` |
136
+ | `auth` | 驗證 Jenkins 認證 | `jenkee auth` |
137
+ | `list-views` | 列出所有 views | `jenkee list-views` |
138
+ | `list-jobs` | 列出 view 中的 jobs | `jenkee list-jobs AVENGERS` |
139
+ | `get-job` | 取得 job XML 配置 | `jenkee get-job <job-name>` |
140
+ | `list-builds` | 列出 job 的 build 歷史 | `jenkee list-builds <job-name>` |
141
+ | `console` | 取得 build console 輸出 | `jenkee console <job-name> [build]` |
142
+ | `job-status` | 查看 job 狀態與觸發關係 | `jenkee job-status <job-name>` |
143
+ | `job-diff` | 比較兩個 job 配置差異 | `jenkee job-diff <job1> <job2>` |
144
+ | `list-credentials` | 列出 Jenkins credentials metadata | `jenkee list-credentials [domain]` |
145
+ | `describe-credentials` | 查看特定 credential 詳細資訊 | `jenkee describe-credentials <id> [--show-secret]` |
146
+ | `add-job-to-view` | 將 jobs 加入到 view | `jenkee add-job-to-view <view> <job> [job ...]` |
147
+ | `copy-job` | 複製 job 為新 job | `jenkee copy-job <source> <destination>` |
148
+ | `update-job` | 更新 job 配置 | `jenkee update-job <job> < config.xml` |
149
+ | `build` | 觸發 job build | `jenkee build <job> [-p key=value] [-s] [-f]` |
150
+ | `stop-builds` | 停止執行中的 builds | `jenkee stop-builds <job> [job ...]` |
151
+ | `create-job` | 建立新 job | `jenkee create-job <job> < config.xml` |
152
+
153
+ 詳細使用說明請參考 [docs/examples/](docs/examples/) 目錄下的各命令文件。
154
+
155
+ 進階與危險命令請參考 [README.advanced.md](README.advanced.md)。
156
+
157
+ ## 主要功能
158
+
159
+ ### 1. 探索 Jenkins 架構
160
+ - 列出所有 views 和 jobs
161
+ - 查看 job 配置與狀態
162
+ - 追蹤 job 觸發關係
163
+
164
+ ### 2. Build 管理
165
+ - 觸發 job builds(支援參數、同步與追蹤模式)
166
+ - 停止執行中的 builds
167
+ - 查看 build 歷史與 console 輸出
168
+
169
+ ### 3. Job 管理
170
+ - 建立、複製、更新 job 配置
171
+ - 比較 job 配置差異
172
+ - 將 jobs 加入 views
173
+
174
+ ### 4. Credentials 管理
175
+ - 列出所有 credentials metadata
176
+ - 查看 credentials 類型與相關資訊
177
+ - 驗證 credentials 配置
178
+
179
+ ## 文件
180
+
181
+ - [README.advanced.md](README.advanced.md) - 進階與危險命令
182
+ - [CODING_GUIDE.md](CODING_GUIDE.md) - 專案開發指南
183
+ - [docs/examples/](docs/examples/) - 各命令使用範例
184
+
185
+ ## 開發指引
186
+
187
+ 如果你是 AI agent 正在開發此專案,請**務必先閱讀 [CODING_GUIDE.md](CODING_GUIDE.md)**。
188
+
189
+ 該文件包含:
190
+ - 專案架構原則與設計模式
191
+ - 新增 command 的完整流程
192
+ - 程式碼格式化規範(Black)
193
+ - AI Agent 開發 checklist
194
+
195
+ 遵循 CODING_GUIDE 可確保:
196
+ - 程式碼風格一致
197
+ - 功能完整實作(包含 help、prompt、example 文件)
198
+ - 通過所有整合測試
199
+
@@ -0,0 +1,66 @@
1
+ jenkins_tools/__init__.py,sha256=CMkiBxRm9bkZeKxNW2ZdEOmsF4ME9sqBBPcoVilXRYI,71
2
+ jenkins_tools/cli.py,sha256=JS0ks2msmrg-tIyL9G3-MnWP_mtMqJDtH3mT44K3CGQ,3674
3
+ jenkins_tools/core.py,sha256=vd7erobj76Q-s8J11Il23lhkeHlspcw2qSVdA7FXo0A,3592
4
+ jenkins_tools/commands/__init__.py,sha256=3v8h66SQ5e2wsA2H0frMkLK0jwqp92Y5_dSKAss5DuM,2025
5
+ jenkins_tools/commands/add_job_to_view.py,sha256=DjHPregjIbDqCAV3nBoh91Hqkbi72_nFQomL0lJK8u4,1778
6
+ jenkins_tools/commands/auth.py,sha256=OnojK7eD-t2xBsmcna0RNT08SR9AwGKqQzhd88h4lyE,2627
7
+ jenkins_tools/commands/build.py,sha256=zUUmusBX-KAsqd_B3-rXJhob6Ag8qi2GWz2UTHxSCiM,2837
8
+ jenkins_tools/commands/console.py,sha256=z9mZ3-b582OMfqb8Y6annEV3b3PgQbdRCB8NX-HJVU0,1589
9
+ jenkins_tools/commands/copy_job.py,sha256=f-ihbh91j1JYsf_8017lVJAusEhBma3Fi7Kogn9Zrd8,1653
10
+ jenkins_tools/commands/create_job.py,sha256=Cq4b72f2GuiIP1kD9RLt6r9S9FEMIXqDOScsdIeO0R4,2261
11
+ jenkins_tools/commands/delete_builds.py,sha256=FTlDOhiP0kodJEWduprxdW1mfH85jdhDJAhEF9wZ6K4,2194
12
+ jenkins_tools/commands/delete_job.py,sha256=Dx1akkgLKWEYE6bvLCG0Flo0M99iChBDtwhoqABDLsw,2275
13
+ jenkins_tools/commands/describe_credentials.py,sha256=zmszGQ1QeEedfvG5NWoKLh5Sww0404mR1ywZOSe_-f8,5525
14
+ jenkins_tools/commands/disable_job.py,sha256=ebdkOXtPzecvU6FNf7twXeUuMzUozygxuXAw1p0ySBg,2287
15
+ jenkins_tools/commands/enable_job.py,sha256=IidT7gajKo0S7ae-bcv9XL0yJQeseHuCy4fWId5xXVs,2275
16
+ jenkins_tools/commands/get_job.py,sha256=XW9O1j-UBfU49XUm--Nk1qLmbfSR_Uk-94nPykt8uxs,1403
17
+ jenkins_tools/commands/groovy.py,sha256=0RpTPsUt1fNW_OylHYpSWfsfYFrF0_gP9tl2Yu5ymo4,2341
18
+ jenkins_tools/commands/help.py,sha256=A59lEUAY6uQu58zrI8RY0BeOGx20G8dBX7_B8fpH3uM,8641
19
+ jenkins_tools/commands/job_diff.py,sha256=zIZx0XK065xSckehO9pgJ3XxAWq0tNw7D6D-wS4TSIk,2251
20
+ jenkins_tools/commands/job_status.py,sha256=t2hr5A7gmAzErk6hjxFiNmR5X1ECREcaQbPYg2urVck,3665
21
+ jenkins_tools/commands/list_builds.py,sha256=c62nV7rLiH_r3ZKnTJGZjQDKVB2KwXnlmoTlkql5gWk,2265
22
+ jenkins_tools/commands/list_credentials.py,sha256=yapRfMhKWK3bOU16PFIBBLKofA_WOJDZYKB7CWH_5ZI,5474
23
+ jenkins_tools/commands/list_jobs.py,sha256=UqfuNgVnP391tthvpwdp8hFz9tYXIfaNn2O3h6Ws4yY,2135
24
+ jenkins_tools/commands/list_views.py,sha256=mfqsdex1wiCf5yaT4Ds4bXjP8E-kpALksl0uA65FFsI,1066
25
+ jenkins_tools/commands/prompt.py,sha256=SeGd1L3D3Wp_9gGWM3J8m5xTFL7GlFupAMsr2JAJVe8,12065
26
+ jenkins_tools/commands/stop_builds.py,sha256=1uyfEJShkm1g9vj0TgEwxl3aFzBUig9nKN37dBsrpDc,2085
27
+ jenkins_tools/commands/update_job.py,sha256=xqaALRVsC9Dy7u_HJilHSaLVIZRAPFgpeDTh3BiIqgM,2036
28
+ jenkins_tools/credential_describers/__init__.py,sha256=E8b3A2HEy5oYzafoYgtf1EwLCGYfHKsgNcOD3glRqW0,1769
29
+ jenkins_tools/credential_describers/azure_credentials.py,sha256=wlJmJ5-ZJ3OUfC5g9GN_Ru_MZ-fgzggOdCoHxR_A6CA,1351
30
+ jenkins_tools/credential_describers/azure_storage_credentials.py,sha256=sUwrfSDaVsKE6RIBmDxjqS4bkCs8e97vsUtwY2qc660,1425
31
+ jenkins_tools/credential_describers/base.py,sha256=Khpj20Hnhml1iW2pG8P7kdtscXhsPLgV4fuI1qCQnb0,2715
32
+ jenkins_tools/credential_describers/browserstack_credentials.py,sha256=ZAtugIvSuFf0kGnzJDeJdAD1ZVRguA-4z4uWoiUcvwY,1063
33
+ jenkins_tools/credential_describers/file_credentials.py,sha256=I9jM88vEl-3eHfA-pYIQbhtECkGHkD0L425PoxC8b8Q,2331
34
+ jenkins_tools/credential_describers/gcp_credentials.py,sha256=zCtA2VSKSAXHC__o5eItbvLtmnYDLSCnPUOpN8ic-R4,2797
35
+ jenkins_tools/credential_describers/gitlab_token_credentials.py,sha256=BvAiY9yV8utEOYuQV9bDnLHXGqMk_FTkf4An1hpj_vU,988
36
+ jenkins_tools/credential_describers/ssh_key_credentials.py,sha256=IJw_q3k2MVEyBF6Pp4LNdCzmAk9IGt0vnqetblGiEFU,2682
37
+ jenkins_tools/credential_describers/string_credentials.py,sha256=U4vjxTmczG5DaoTtoEtkLCDqG2esWpvUIEk691tpet0,1781
38
+ jenkins_tools/credential_describers/username_password_credentials.py,sha256=59BVJNHoUaYJaJj7wXe45wqIZu7LYhSr7AxJt3r_hgE,2118
39
+ jenkins_tools/docs/examples/add-job-to-view.md,sha256=eitZEeLClGUwTCoGm8K2tTOSCNRKx08uKBTUfBdgceA,4021
40
+ jenkins_tools/docs/examples/auth.md,sha256=9eHM6Ro6zrvw7BSy1hQF8qY2-Ga6TKqVipGWFvSVpWE,2733
41
+ jenkins_tools/docs/examples/build.md,sha256=DHX1kK8RHuszb-hg9jCTpx0ZlpjYSBFb8tuiXOz-Eyc,5836
42
+ jenkins_tools/docs/examples/console.md,sha256=s2RU1IIHUpoRVGmtEDLGA4Lz2-AkHzLqVxRjDV5ZJd4,7094
43
+ jenkins_tools/docs/examples/copy-job.md,sha256=MUwVHC8QgUyHZPonoOn8dLg8A-LFmAE6filO9Ei3-k4,6237
44
+ jenkins_tools/docs/examples/create-job.md,sha256=0ec7lsEGCsqs1YU6ltb3reLjumNWJFROhX9GXbeJjqs,7031
45
+ jenkins_tools/docs/examples/delete-builds.md,sha256=DX5_DYAJ2gsqiNrjy_EqExsnY24H6d7PUwzsbf_tFew,7853
46
+ jenkins_tools/docs/examples/delete-job.md,sha256=3NrN8y1JaRXxbu7fvCyWcLGXAyETSx2TXXh6empbszE,6982
47
+ jenkins_tools/docs/examples/describe-credentials.md,sha256=vNCEtGO76QKbIKIrvek3MSfft3dVyKUEhoeEh0kYdq0,10309
48
+ jenkins_tools/docs/examples/disable-job.md,sha256=bJWau6lpJ3hMk7rMG2EciaS8n67nMwtvrbkw-9qKbk8,4583
49
+ jenkins_tools/docs/examples/enable-job.md,sha256=hWc0rNO0SzkiUtp4xwPd43CGU-n3Mz5QWUvZ6G3r6kM,4964
50
+ jenkins_tools/docs/examples/get-job.md,sha256=j4Le-pGIJ8npZ_ijREhjDBAAf0aUQHD2_S9Oxuuaprs,4400
51
+ jenkins_tools/docs/examples/groovy.md,sha256=Z3Lt2SjSCKuZOKY14vBDn69tKpQ5zzHmrtSQZBuMVPA,4762
52
+ jenkins_tools/docs/examples/help.md,sha256=FvNrLMDJlOgPRKzT8mUOF3OfKNViWYyOjq8mqGzTKv8,3780
53
+ jenkins_tools/docs/examples/job-diff.md,sha256=7AXHVlSHsRqUV1yCgy7FMe5TLEIffcXLP85n3qmEvKo,8320
54
+ jenkins_tools/docs/examples/job-status.md,sha256=KdXJlNdNKjdoAl_KQ45OXRMV7oyFeAo0Iz-EjwskdrA,5849
55
+ jenkins_tools/docs/examples/list-builds.md,sha256=JUj75nxVONIIYQyJaJAj2VLy_atQ5wgpYF9wH01nh3k,2509
56
+ jenkins_tools/docs/examples/list-credentials.md,sha256=j2aJF7FBwsBro-26zNWooUflZK9VaQH2mF-MieOGbGQ,11676
57
+ jenkins_tools/docs/examples/list-jobs.md,sha256=Y8T5TwtRBC0u_reg6SdH8QbJGHmjKUv-82d_fU8tpho,3678
58
+ jenkins_tools/docs/examples/list-views.md,sha256=BDzJxbv_nlk8v-p1t0WRrcFBeV8bh0_sUlWoVpPAC0Q,2196
59
+ jenkins_tools/docs/examples/prompt.md,sha256=bjyYcpcX8n5WEmZe2ROwp1kSL4nHQXztIFCSJ7vzeRA,9084
60
+ jenkins_tools/docs/examples/stop-builds.md,sha256=9lb18mtqLL0JpfNvK8J9sADqh3CDZXz6kIvCQgRbrHY,6684
61
+ jenkins_tools/docs/examples/update-job.md,sha256=38pRLLJZknXI_7HfGvR4p6Yx_JJtUYmHwjogig8vdx4,10023
62
+ jenkee-0.2.1.dist-info/METADATA,sha256=cf5rqkiZ-EPZzRzumlaw5toBdsz-4vxhRt80MK-PU58,6060
63
+ jenkee-0.2.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
64
+ jenkee-0.2.1.dist-info/entry_points.txt,sha256=7A2X1kU1CPsfU_Em3rVRDG6Q3ri5K72HMQD_QjclTGw,79
65
+ jenkee-0.2.1.dist-info/top_level.txt,sha256=gmeLT1Of77N2MmmQfLTNf8ZC0bDFR1xD6beCcLswX-s,14
66
+ jenkee-0.2.1.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.9.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ jenkee = jenkins_tools.cli:main
3
+ jks = jenkins_tools.cli:main
@@ -0,0 +1 @@
1
+ jenkins_tools
@@ -0,0 +1,3 @@
1
+ """Jenkins Studio - Jenkins CLI Helper Tools"""
2
+
3
+ __version__ = "0.2.1"
jenkins_tools/cli.py ADDED
@@ -0,0 +1,120 @@
1
+ """Jenkins CLI main entry point"""
2
+
3
+ import sys
4
+ from pathlib import Path
5
+
6
+ from jenkins_tools.commands import (
7
+ AuthCommand,
8
+ ListViewsCommand,
9
+ ListJobsCommand,
10
+ GetJobCommand,
11
+ ListBuildsCommand,
12
+ ConsoleCommand,
13
+ JobStatusCommand,
14
+ JobDiffCommand,
15
+ ListCredentialsCommand,
16
+ DescribeCredentialsCommand,
17
+ AddJobToViewCommand,
18
+ CopyJobCommand,
19
+ UpdateJobCommand,
20
+ BuildCommand,
21
+ StopBuildsCommand,
22
+ CreateJobCommand,
23
+ DeleteJobCommand,
24
+ DisableJobCommand,
25
+ EnableJobCommand,
26
+ DeleteBuildsCommand,
27
+ GroovyCommand,
28
+ HelpCommand,
29
+ PromptCommand,
30
+ )
31
+
32
+
33
+ def main():
34
+ """Main entry point for CLI command"""
35
+ program_name = Path(sys.argv[0]).name if sys.argv else "jenkee"
36
+ if len(sys.argv) < 2:
37
+ # 沒有參數時顯示命令列表
38
+ cmd = HelpCommand()
39
+ sys.exit(cmd.execute())
40
+
41
+ command = sys.argv[1]
42
+
43
+ # Dispatch to appropriate command
44
+ if command == "auth":
45
+ cmd = AuthCommand()
46
+ sys.exit(cmd.execute())
47
+ elif command == "list-views":
48
+ cmd = ListViewsCommand()
49
+ sys.exit(cmd.execute())
50
+ elif command == "list-jobs":
51
+ cmd = ListJobsCommand(sys.argv[2:])
52
+ sys.exit(cmd.execute())
53
+ elif command == "get-job":
54
+ cmd = GetJobCommand(sys.argv[2:])
55
+ sys.exit(cmd.execute())
56
+ elif command == "list-builds":
57
+ cmd = ListBuildsCommand(sys.argv[2:])
58
+ sys.exit(cmd.execute())
59
+ elif command == "console":
60
+ cmd = ConsoleCommand(sys.argv[2:])
61
+ sys.exit(cmd.execute())
62
+ elif command == "job-status":
63
+ cmd = JobStatusCommand(sys.argv[2:])
64
+ sys.exit(cmd.execute())
65
+ elif command == "job-diff":
66
+ cmd = JobDiffCommand(sys.argv[2:])
67
+ sys.exit(cmd.execute())
68
+ elif command == "list-credentials":
69
+ cmd = ListCredentialsCommand(sys.argv[2:])
70
+ sys.exit(cmd.execute())
71
+ elif command == "describe-credentials":
72
+ cmd = DescribeCredentialsCommand(sys.argv[2:])
73
+ sys.exit(cmd.execute())
74
+ elif command == "add-job-to-view":
75
+ cmd = AddJobToViewCommand(sys.argv[2:])
76
+ sys.exit(cmd.execute())
77
+ elif command == "copy-job":
78
+ cmd = CopyJobCommand(sys.argv[2:])
79
+ sys.exit(cmd.execute())
80
+ elif command == "update-job":
81
+ cmd = UpdateJobCommand(sys.argv[2:])
82
+ sys.exit(cmd.execute())
83
+ elif command == "build":
84
+ cmd = BuildCommand(sys.argv[2:])
85
+ sys.exit(cmd.execute())
86
+ elif command == "stop-builds":
87
+ cmd = StopBuildsCommand(sys.argv[2:])
88
+ sys.exit(cmd.execute())
89
+ elif command == "create-job":
90
+ cmd = CreateJobCommand(sys.argv[2:])
91
+ sys.exit(cmd.execute())
92
+ elif command == "delete-job":
93
+ cmd = DeleteJobCommand(sys.argv[2:])
94
+ sys.exit(cmd.execute())
95
+ elif command == "disable-job":
96
+ cmd = DisableJobCommand(sys.argv[2:])
97
+ sys.exit(cmd.execute())
98
+ elif command == "enable-job":
99
+ cmd = EnableJobCommand(sys.argv[2:])
100
+ sys.exit(cmd.execute())
101
+ elif command == "delete-builds":
102
+ cmd = DeleteBuildsCommand(sys.argv[2:])
103
+ sys.exit(cmd.execute())
104
+ elif command == "groovy":
105
+ cmd = GroovyCommand(sys.argv[2:])
106
+ sys.exit(cmd.execute())
107
+ elif command == "prompt":
108
+ cmd = PromptCommand(sys.argv[2:])
109
+ sys.exit(cmd.execute())
110
+ elif command == "help":
111
+ cmd = HelpCommand(sys.argv[2:])
112
+ sys.exit(cmd.execute())
113
+ else:
114
+ print(f"Error: Unknown command '{command}'", file=sys.stderr)
115
+ print(f"Run '{program_name} help' to see available commands", file=sys.stderr)
116
+ sys.exit(1)
117
+
118
+
119
+ if __name__ == "__main__":
120
+ main()
@@ -0,0 +1,51 @@
1
+ """Jenkins CLI commands"""
2
+
3
+ from jenkins_tools.commands.auth import AuthCommand
4
+ from jenkins_tools.commands.list_views import ListViewsCommand
5
+ from jenkins_tools.commands.list_jobs import ListJobsCommand
6
+ from jenkins_tools.commands.get_job import GetJobCommand
7
+ from jenkins_tools.commands.list_builds import ListBuildsCommand
8
+ from jenkins_tools.commands.console import ConsoleCommand
9
+ from jenkins_tools.commands.job_status import JobStatusCommand
10
+ from jenkins_tools.commands.job_diff import JobDiffCommand
11
+ from jenkins_tools.commands.list_credentials import ListCredentialsCommand
12
+ from jenkins_tools.commands.describe_credentials import DescribeCredentialsCommand
13
+ from jenkins_tools.commands.add_job_to_view import AddJobToViewCommand
14
+ from jenkins_tools.commands.copy_job import CopyJobCommand
15
+ from jenkins_tools.commands.update_job import UpdateJobCommand
16
+ from jenkins_tools.commands.build import BuildCommand
17
+ from jenkins_tools.commands.stop_builds import StopBuildsCommand
18
+ from jenkins_tools.commands.create_job import CreateJobCommand
19
+ from jenkins_tools.commands.delete_job import DeleteJobCommand
20
+ from jenkins_tools.commands.disable_job import DisableJobCommand
21
+ from jenkins_tools.commands.enable_job import EnableJobCommand
22
+ from jenkins_tools.commands.delete_builds import DeleteBuildsCommand
23
+ from jenkins_tools.commands.groovy import GroovyCommand
24
+ from jenkins_tools.commands.help import HelpCommand
25
+ from jenkins_tools.commands.prompt import PromptCommand
26
+
27
+ __all__ = [
28
+ "AuthCommand",
29
+ "ListViewsCommand",
30
+ "ListJobsCommand",
31
+ "GetJobCommand",
32
+ "ListBuildsCommand",
33
+ "ConsoleCommand",
34
+ "JobStatusCommand",
35
+ "JobDiffCommand",
36
+ "ListCredentialsCommand",
37
+ "DescribeCredentialsCommand",
38
+ "AddJobToViewCommand",
39
+ "CopyJobCommand",
40
+ "UpdateJobCommand",
41
+ "BuildCommand",
42
+ "StopBuildsCommand",
43
+ "CreateJobCommand",
44
+ "DeleteJobCommand",
45
+ "DisableJobCommand",
46
+ "EnableJobCommand",
47
+ "DeleteBuildsCommand",
48
+ "GroovyCommand",
49
+ "HelpCommand",
50
+ "PromptCommand",
51
+ ]
@@ -0,0 +1,57 @@
1
+ """Add jobs to view command"""
2
+
3
+ import sys
4
+
5
+ from jenkins_tools.core import Command, JenkinsConfig, JenkinsCLI
6
+
7
+
8
+ class AddJobToViewCommand(Command):
9
+ """Add one or more jobs to a Jenkins view"""
10
+
11
+ def __init__(self, args):
12
+ """
13
+ Initialize with command line arguments
14
+
15
+ Args:
16
+ args: List of command arguments (sys.argv[2:])
17
+ First argument is view name, rest are job names
18
+ """
19
+ self.args = args
20
+
21
+ def execute(self) -> int:
22
+ """Execute add-job-to-view command"""
23
+ config = JenkinsConfig()
24
+
25
+ # Check if credentials are configured
26
+ if not config.is_configured():
27
+ print("Error: Jenkins credentials not configured.", file=sys.stderr)
28
+ print(f"Run 'jks auth' to configure credentials.", file=sys.stderr)
29
+ return 1
30
+
31
+ # Parse arguments
32
+ if len(self.args) < 2:
33
+ print("Error: View name and at least one job name are required.", file=sys.stderr)
34
+ print(
35
+ "Usage: jks add-job-to-view <view-name> <job-name> [job-name ...]", file=sys.stderr
36
+ )
37
+ return 1
38
+
39
+ view_name = self.args[0]
40
+ job_names = self.args[1:]
41
+
42
+ # Use Jenkins CLI to add jobs to view
43
+ cli = JenkinsCLI(config)
44
+ result = cli.run("add-job-to-view", view_name, *job_names)
45
+
46
+ if result.returncode != 0:
47
+ print(f"Error: Failed to add jobs to view '{view_name}'", file=sys.stderr)
48
+ if result.stderr:
49
+ print(result.stderr, file=sys.stderr)
50
+ return 1
51
+
52
+ # Success
53
+ print(f"✓ Successfully added {len(job_names)} job(s) to view '{view_name}'")
54
+ for job in job_names:
55
+ print(f" - {job}")
56
+
57
+ return 0
@@ -0,0 +1,67 @@
1
+ """Authentication command"""
2
+
3
+ import sys
4
+ from pathlib import Path
5
+
6
+ from jenkins_tools.core import Command, JenkinsConfig, JenkinsCLI
7
+
8
+
9
+ class AuthCommand(Command):
10
+ """Verify Jenkins authentication"""
11
+
12
+ def execute(self) -> int:
13
+ """Execute auth command - verify credentials by running whoami"""
14
+ config = JenkinsConfig()
15
+
16
+ # Check if credentials are configured
17
+ if not config.is_configured():
18
+ print("Error: Jenkins credentials not configured.", file=sys.stderr)
19
+ print("", file=sys.stderr)
20
+ print(f"Please create a .env file at: {config.env_path}", file=sys.stderr)
21
+ if config.legacy_env_path.exists() and not config.env_path.exists():
22
+ print("", file=sys.stderr)
23
+ print(
24
+ f"Detected legacy config at: {config.legacy_env_path}",
25
+ file=sys.stderr,
26
+ )
27
+ print(
28
+ f"Please move it to: {config.env_path}",
29
+ file=sys.stderr,
30
+ )
31
+ print("", file=sys.stderr)
32
+ print("Content:", file=sys.stderr)
33
+ print(" JENKINS_URL=http://your-jenkins-server:8080/", file=sys.stderr)
34
+ print(" JENKINS_USER_ID=your_email@example.com", file=sys.stderr)
35
+ print(" JENKINS_API_TOKEN=your_api_token", file=sys.stderr)
36
+ print("", file=sys.stderr)
37
+ print("You can get your API token from:", file=sys.stderr)
38
+ print(" Jenkins > User > Configure > API Token", file=sys.stderr)
39
+ return 1
40
+
41
+ # Run who-am-i to verify authentication
42
+ cli = JenkinsCLI(config)
43
+ print("Verifying authentication...")
44
+
45
+ result = cli.run("who-am-i")
46
+
47
+ if result.returncode == 0:
48
+ output = (result.stdout or "").strip()
49
+ lines = [line for line in output.splitlines() if line.strip()]
50
+ if lines:
51
+ first_line = lines[0]
52
+ if first_line.startswith("Authenticated as:"):
53
+ print(f"✓ {first_line}")
54
+ if len(lines) > 1:
55
+ print("\n".join(lines[1:]))
56
+ else:
57
+ print(f"✓ Authenticated as: {first_line}")
58
+ if len(lines) > 1:
59
+ print("\n".join(lines[1:]))
60
+ else:
61
+ print("✓ Authentication successful")
62
+ return 0
63
+ else:
64
+ print("✗ Authentication failed", file=sys.stderr)
65
+ if result.stderr:
66
+ print(result.stderr, file=sys.stderr)
67
+ return 1
@@ -0,0 +1,83 @@
1
+ """Build command"""
2
+
3
+ import sys
4
+
5
+ from jenkins_tools.core import Command, JenkinsConfig, JenkinsCLI
6
+
7
+
8
+ class BuildCommand(Command):
9
+ """Trigger a Jenkins job build"""
10
+
11
+ def __init__(self, args=None):
12
+ """
13
+ Initialize with command line arguments
14
+
15
+ Args:
16
+ args: List of command arguments (sys.argv[2:])
17
+ First argument is job name
18
+ Optional flags: -p key=value (multiple), -s, -f, -v
19
+ """
20
+ self.args = args or []
21
+
22
+ def execute(self) -> int:
23
+ """Execute build command"""
24
+ config = JenkinsConfig()
25
+
26
+ # Check if credentials are configured
27
+ if not config.is_configured():
28
+ print("Error: Jenkins credentials not configured.", file=sys.stderr)
29
+ print(f"Run 'jenkee auth' to configure credentials.", file=sys.stderr)
30
+ return 1
31
+
32
+ # Parse arguments
33
+ if not self.args:
34
+ print("Error: Missing job name", file=sys.stderr)
35
+ print(
36
+ "Usage: jenkee build <job-name> [-p key=value ...] [-s] [-f] [-v]", file=sys.stderr
37
+ )
38
+ print("", file=sys.stderr)
39
+ print("Options:", file=sys.stderr)
40
+ print(" -p key=value Build parameters (can be used multiple times)", file=sys.stderr)
41
+ print(" -s Wait until build completion", file=sys.stderr)
42
+ print(" -f Follow build progress (implies -s)", file=sys.stderr)
43
+ print(" -v Print console output (use with -s or -f)", file=sys.stderr)
44
+ return 1
45
+
46
+ job_name = self.args[0]
47
+
48
+ # Parse flags and parameters
49
+ cli_args = []
50
+ i = 1
51
+ while i < len(self.args):
52
+ arg = self.args[i]
53
+ if arg == "-p" and i + 1 < len(self.args):
54
+ # Build parameter
55
+ cli_args.append("-p")
56
+ cli_args.append(self.args[i + 1])
57
+ i += 2
58
+ elif arg in ["-s", "-f", "-v"]:
59
+ # Boolean flags
60
+ cli_args.append(arg)
61
+ i += 1
62
+ else:
63
+ print(f"Error: Unknown option '{arg}'", file=sys.stderr)
64
+ return 1
65
+
66
+ # Execute build command
67
+ cli = JenkinsCLI(config)
68
+ result = cli.run("build", job_name, *cli_args)
69
+
70
+ if result.returncode == 0:
71
+ # Success
72
+ output = result.stdout.strip() if result.stdout else ""
73
+ if output:
74
+ print(output)
75
+ else:
76
+ print(f"✓ Build triggered for job '{job_name}'")
77
+ return 0
78
+ else:
79
+ # Failure
80
+ print(f"Error: Failed to build job '{job_name}'", file=sys.stderr)
81
+ if result.stderr:
82
+ print(result.stderr, file=sys.stderr)
83
+ return 1