前言
当我们的 jenkins
服务所在的机器无法在外部访问,或者端口不通的时候,我们想要查看 jenkins
上的项目情况就很难,这个时候我们怎么办呢?我推荐给你们一种最简单的工具。
jenkinsclient
jenkinsclient
是一个 python
的第三方包,安装简单,使用方便,是优秀的 jenkins
第三方客户端工具。
安装
pip3 install jenkinsclient
配置
# 1、生成配置文件(位于/root/.jenkinsclient.yaml)
jenkins config generate
# 2、配置jenkins信息
vi /root/.jenkinsclient.yaml
# 根据实际情况修改,模板如下
jenkins_servers:
- name: default
url: http://0:8080
username: 'admin'
token: 'pwd@123'
use: default
使用
# 1、查看项目列表
[root@localhost ~]# jenkins jobs
任务名称 类型 链接
-------- -------- --------
Auto_Test_Pipline WorkflowJob http://x.x.x.22:8888/job/Auto_Test_Pipline/
xxx-FT-Pipline FreeStyleProject http://x.x.x.22:8888/job/xxz-FT-Pipline/
[root@localhost ~]#
# 2、查看项目详情
[root@localhost ~]# jenkins job info Auto_Test_Pipline
actions: [{}, {}, {}, {}, {}, {}, {}, {}, {"_class": "com.cloudbees.plugins.credentials.ViewCredentialsAction"}]
description: null
displayName: Auto_Test_Pipline
displayNameOrNull: null
fullDisplayName: Auto_Test_Pipline
fullName: Auto_Test_Pipline
name: Auto_Test_Pipline
url: http://x.x.x.22:8888/job/Auto_Test_Pipline/
buildable: true
builds: [{"_class": "org.jenkinsci.plugins.workflow.job.WorkflowRun", "number": 1, "url": "http://x.x.x.22:8888/job/Auto_Test_Pipline/1/"}]
color: red
firstBuild: {"_class": "org.jenkinsci.plugins.workflow.job.WorkflowRun", "number": 1, "url": "http://x.x.x.22:8888/job/Auto_Test_Pipline/1/"}
healthReport: [{"description": "Build stability: All recent builds failed.", "iconClassName": "icon-health-00to19", "iconUrl": "health-00to19.png", "score": 0}]
inQueue: false
keepDependencies: false
lastBuild: {"_class": "org.jenkinsci.plugins.workflow.job.WorkflowRun", "number": 1, "url": "http://x.x.x.22:8888/job/Auto_Test_Pipline/1/"}
lastCompletedBuild: {"_class": "org.jenkinsci.plugins.workflow.job.WorkflowRun", "number": 1, "url": "http://x.x.x.22:8888/job/Auto_Test_Pipline/1/"}
lastFailedBuild: {"_class": "org.jenkinsci.plugins.workflow.job.WorkflowRun", "number": 1, "url": "http://x.x.x.22:8888/job/Auto_Test_Pipline/1/"}
lastStableBuild: null
lastSuccessfulBuild: null
lastUnstableBuild: null
lastUnsuccessfulBuild: {"_class": "org.jenkinsci.plugins.workflow.job.WorkflowRun", "number": 1, "url": "http://x.x.x.22:8888/job/Auto_Test_Pipline/1/"}
nextBuildNumber: 2
property: []
queueItem: null
concurrentBuild: true
resumeBlocked: false
# 3、查看slave列表
[root@localhost ~]# jenkins nodes
节点名称 架构 可用交换空间 可用内存空间 可用临时空间 可用磁盘空间
-------- -------- -------- -------- -------- --------
(master) Linux (amd64) 799.23/4096.0 MB 389.78/128385.95 MB 3220446 MB 3220446 MB
Test_VM_10.x.x.x Linux (amd64) 0.0/0.0 MB 30587.82/32003.24 MB9387 MB 17359 MB
Test_VM_10.x.x.x Linux (amd64) 3968.0/3968.0 MB 12455.17/15884.35 MB43546 MB 24488 MB
[root@localhost ~]#
怎么样,是不是很简单呢!
更多用法请移步:https://pypi.org/project/jenkinsclient/2.0/
以上就是今天的全部内容了,感谢您的阅读,我们下节再会。
评论区