Jenkins 是强大的自动化工具。
本文介绍如果通过 jcli(Jenkins Client)来管理 Jenkins 站点
环境
- 启动 Jenkins Service
安装
Linux 下的用户,可通过一下命令安装 jcli
|
|
##使用
在使用 jcli
工具之前,需要先生成一份配置文件。
|
|
可以登录到 jenkins 页面上去 User -> Configure -> API Token 生成一个 token 填入到上面对应字段。
jcli -h
|
|
可以看出 jcli
里面涵盖了许多子命令,为了方便查询,jcli
提供了生成命令文档的功能
jcli doc [PATH]
在导出目录下:
里面的内容为:
常用命令
由于命令繁多,这里列出一些比较常用的命令,更多的功能请参阅上面生成的文档。
Center
- jcli center download - Download jenkins.war
- jcli center identity - Print the identity of current Jenkins
- jcli center mirror - Set the update center to a mirror address
- jcli center start - Start Jenkins server from a cache directory
- jcli center upgrade - Upgrade your Jenkins
- jcli center watch - Watch your update center status
Config
- jcli config add - Add a Jenkins config item
- jcli config clean - Clean up some unavailable config items
- jcli config edit - Edit a Jenkins config
- jcli config generate - Generate a sample config file for you
- jcli config list - List all Jenkins config items
- jcli config plugin - Manage plugins for jcli
- jcli config plugin - Manage plugins for jcli
- jcli config remove - Remove a Jenkins config
- jcli config select - Select one config as current Jenkins
Credential
- jcli credential create - Create a credential from Jenkins
- jcli credential delete - Delete a credential from Jenkins
- jcli credential list - List all credentials of Jenkins
Job
- jcli job artifact - Print the artifact list of target job
- jcli job build - Build the job of your Jenkins
- jcli job create - Create a job in your Jenkins
- jcli job delete - Delete a job in your Jenkins
- jcli job disable - Disable a job in your Jenkins
- jcli job edit - Edit the job of your Jenkins
- jcli job enable - Enable a job in your Jenkins
- jcli job history - Print the history of job in your Jenkins
- jcli job input - Input a job in your Jenkins
- jcli job log - Print the job's log of your Jenkins
- jcli job param - Get parameters of the job of your Jenkins
- jcli job search - Print the job of your Jenkins
- jcli job stop - Stop a job build in your Jenkins
- jcli job type - Print the types of job which in your Jenkins
Plugin
- jcli plugin build - Build the Jenkins plugin project
- jcli plugin check - Check update center server
- jcli plugin create - Create a plugin project from the archetypes
- jcli plugin download - Download the plugins
- jcli plugin install - Install the plugins
- jcli plugin list - Print all the plugins which are installed
- jcli plugin open - Open update center server in browser
- jcli plugin release - Release current plugin project
- jcli plugin search - Print the plugins of your Jenkins
- jcli plugin trend - Show the trend of the plugin
- jcli plugin uninstall - Uninstall the plugins
- jcli plugin upgrade - Upgrade the specific plugin
- jcli plugin upload - Upload a plugin to your Jenkins
User
- jcli user create - Create a user for your Jenkins
- jcli user delete - Delete a user for your Jenkins
- jcli user edit - Edit the user of your Jenkins
- jcli user token - Token the user of your Jenkins
Jenkins
jcli restart
- Restart your Jenkinsjcli shutdown
- Puts Jenkins into the quiet mode, wait for existing builds to be completed, and then shut down Jenkinsjcli runner
- The wrapper of jenkinsfile runner Get more about jenkinsfile runner from https://github.com/jenkinsci/jenkinsfile-runnerjcli shell
- Create a sub shell so that changes to a specific Jenkins remain local to the shell.