- 浏览: 21383 次
- 性别:
- 来自: 北京
文章分类
最新评论
假设Jenkins的URL为http://22.11.140.38:9080/jenkins/
基本的格式为
java
基本的格式为
java -jar jenkins-cli.jar [-s JENKINS_URL] command [options][args]
下面具体介绍各个命令的作用及基本使用方法
1. help 查看所有内嵌命令的基本功能 无参数
Eg.
java -jar jenkins-cli.jar -s http://22.11.140.38:9080/jenkins/ help
2. build 执行一次构建
参数说明:
JOB : Name of the job to build 要构建的job名称
-c : Check for SCM changes before starting the build, and if
there's no change, exit without doing a build
-p : Specify the build parameters in the key=value format.
-r VAL : Number of times to retry reading of the output log if it
does not exists on first attempt. Defaults to 0. Use
with -v.
-s : Wait until the completion/abortion of the command
-v : Prints out the console output of the build. Use with -s
-w : Wait until the start of the command
--username VAL : User name to authenticate yourself to Jenkins
--password VAL : Password for authentication. Note that passing a
password in arguments is insecure.
--password-file VAL : File that contains the password
3. cancel-quiet-down: Cancel the effect of the "quiet-down" command.
4. clear-queue: Clears the build queue
5. connect-node: Reconnect to a node
6. console: Retrieves console output of a build 显示某job某次构建的的控制台输出
参数说明:
JOB : Name of the job
BUILD : Build number or permalink to point to the build.
Defaults to the last build
-f : If the build is in progress, stay around and append
console output as it comes, like 'tail -f'
-n N : Display the last N lines
--username VAL : User name to authenticate yourself to Jenkins
--password VAL : Password for authentication. Note that passing a
password in arguments is insecure.
--password-file VAL : File that contains the password
7. copy-job: Copies a job
参数说明:
SRC : Name of the job to copy
DST : Name of the new job to be created.
--username VAL : User name to authenticate yourself to Jenkins
--password VAL : Password for authentication. Note that passing a
password in arguments is insecure.
--password-file VAL : File that contains the password
8. create-job: Creates a new job by reading stdin as a configuration XML file.
从一个XML文档中创建一个job
Eg.
java -jar /home/jboss/.jenkins/jenkins-cli.jar -s http://22.11.140.61:9080/jenkins/ create-job testttt
9. create-node: Creates a new node by reading stdin as a XML configuration.
10. delete-builds: Deletes build record(s)
参数说明:
JOB : Name of the job to build
RANGE : Range of the build records to delete. 'N-M', 'N,M', or
'N'
--username VAL : User name to authenticate yourself to Jenkins
--password VAL : Password for authentication. Note that passing a
password in arguments is insecure.
--password-file VAL : File that contains the password
Eg.
java -jar /home/jboss/.jenkins/jenkins-cli.jar -s http://22.11.140.61:9080/jenkins/ delete-builds 3-5
11. delete-job
参数说明:
NAME : Job name
--username VAL : User name to authenticate yourself to Jenkins
--password VAL : Password for authentication. Note that passing a
password in arguments is insecure.
--password-file VAL : File that contains the password
12. delete-node Deletes a node
13. disable-job Disables a job 相当于“停止构建”
参数说明:
NAME : Job name
--username VAL : User name to authenticate yourself to Jenkins
--password VAL : Password for authentication. Note that passing a
password in arguments is insecure.
--password-file VAL : File that contains the password
14. disconnect-node Disconnects from a node
15. enable-job Enables a job 相当于恢复可构建状态
参数说明:
NAME : Job name
--username VAL : User name to authenticate yourself to Jenkins
--password VAL : Password for authentication. Note that passing a
password in arguments is insecure.
--password-file VAL : File that contains the password
16. get-job Dumps the job definition XML to stdout 得到job定义的XML文档
参数说明:
JOB : Name of the job
--username VAL : User name to authenticate yourself to Jenkins
--password VAL : Password for authentication. Note that passing a
password in arguments is insecure.
--password-file VAL : File that contains the password
17. get-node Dumps the node definition XML to stdout
18. groovy Executes the specified Groovy script.
19. groovysh Runs an interactive groovy shell.
20. help Lists all the available commands. 无参数
21. install-plugin Installs a plugin either from a file, an URL, or from update center. 安装插件
22. install-tool Performs automatic tool installation, and print its location to stdout. Can be only called from inside a build.
23. keep-build Mark the build to keep the build forever.
24. list-changes Dumps the changelog for the specified build(s).输出某一次或几次构建的变更记录
参数说明:
JOB : Name of the job to build
RANGE : Range of the build records to delete. 'N-M',
'N,M', or 'N'
-format [XML | CSV | PLAIN] : Controls how the output from this command is
printed.
--username VAL : User name to authenticate yourself to Jenkins
--password VAL : Password for authentication. Note that passing a
password in arguments is insecure.
--password-file VAL : File that contains the password
25. list-jobs Lists all jobs in a specific view or item group.列出所有的jobs名称,其后可以接视图名称,默认显示全部
Eg.
java -jar /home/jboss/.jenkins/jenkins-cli.jar -s http://22.11.140.61:9080/jenkins/ list-jobs viewname
26. list-plugins Outputs a list of installed plugins. 列出安装的所有插件
27. login Saves the current credential to allow future commands to run without explicit credential information.保存登录状态
参数说明:
--username VAL : User name to authenticate yourself to Jenkins
--password VAL : Password for authentication. Note that passing a
password in arguments is insecure.
--password-file VAL : File that contains the password
28. logout Deletes the credential stored with the login command. 注销
29. mail Reads stdin and sends that out as an e-mail.
30. offline-node Stop using a node for performing builds temporarily, until the next "online-node" command.
31. online-node Resume using a node for performing builds, to cancel out the earlier "offline-node" command.
32. quiet-down Quiet down Jenkins, in preparation for a restart. Don?. start any builds.
33. reload-configuration Discard all the loaded data in memory and reload everything from file system. Useful when you modified config files directly on disk.重新加载配置文件无参数
34. restart Restart Jenkins 重启Jenkins
35. safe-restart Safely restart Jenkins 安全重启Jenkins,即等待已有的构建完成再重启
36. safe-shutdown Puts Jenkins into the quiet mode, wait for existing builds to be completed, and then shut down Jenkins.安全关闭Jenkins
37. session-id Outputs the session ID, which changes every time Jenkins restarts
38. set-build-description Sets the description of a build.为已有构建添加描述
参数说明:
JOB : Name of the job to build
BUILD# : Number of the build
DESCRIPTION : Description to be set. '=' to read from stdin.
--username VAL : User name to authenticate yourself to Jenkins
--password VAL : Password for authentication. Note that passing a
password in arguments is insecure.
--password-file VAL : File that contains the password
39. set-build-display-name Sets the displayName of a build重命名默认的构建编号
参数说明:
JOB : Name of the job to build
BUILD# : Number of the build
DISPLAYNAME : DisplayName to be set. '-' to read from stdin.
--username VAL : User name to authenticate yourself to Jenkins
--password VAL : Password for authentication. Note that passing a
password in arguments is insecure.
--password-file VAL : File that contains the password
40. set-build-parameter Update/set the build parameter of the current build in progress
参数说明:
NAME : Name of the build variable
VALUE : Value of the build variable
--username VAL : User name to authenticate yourself to Jenkins
--password VAL : Password for authentication. Note that passing a
password in arguments is insecure.
--password-file VAL : File that contains the password
41. set-build-result Sets the result of the current build. Works only if invoked from within a build.
42. shutdown Immediately shuts down Jenkins server 立即关闭jenkins
43. update-job Updates the job definition XML from stdin. The opposite of the get-job command
44. update-node Updates the node definition XML from stdin. The opposite of the get-node command
45. version Outputs the current version. 查看当前版本
46. wait-node-offline Wait for a node to become offline
47. wait-node-online Wait for a node to become online
48. who-am-i Reports your credential and permissions 查看当前登录用户
Tips:为了操作方便,建议先通过login命令保存登录状态,这样就不需要每次执行操作都加上用户名密码参数了;缺点是安全性不好,记得操作结束之后logout
相关推荐
文档提供了详细的步骤说明,帮助初学者快速掌握Jenkins的使用方法。 以上知识点涵盖了Jenkins的基本安装、配置、构建Job、远程任务执行、Pipeline的使用、证书配置等关键操作,以及一些高级特性的简单介绍,为初学...
描述中的内容重复了标题的信息,强调“bartlett”是一个简单的Jenkins命令行客户端,暗示其设计注重易用性和实用性,适合那些希望通过命令行快速操作Jenkins的用户。这可能包括触发构建、查看构建状态、获取日志等...
在Jenkins的工作空间中,你可以找到构建后的文件,并通过脚本将其复制到指定位置。例如,可以创建一个批处理脚本来启动Java应用程序。 【Jenkins本地部署与发布】 若要将项目部署到Windows服务器,首先需要在...
2. **命令行调用**:用户可以指定一个`Jenkinsfile`路径,然后通过命令行调用Jenkinsfile Runner执行该文件,就像执行一般的命令一样。 3. **执行流程**:Jenkinsfile Runner读取`Jenkinsfile`,解析其中的步骤,并...
3. **启动Jenkins**:你可以通过命令行启动Jenkins,例如在Unix/Linux系统上使用`java -jar jenkins.war`命令,或者将Jenkins配置为服务以后台方式运行。 4. **初次配置**:启动后,Jenkins会提供一个初始化URL,你...
建议仔细阅读这份文档,按照指导一步步操作,同时实践是掌握Jenkins的最佳方式。在学习过程中,你可能会遇到各种问题,但不要担心,Jenkins拥有庞大的社区和丰富的在线资源,可以随时查找解决方案。祝你在Jenkins的...
1. **下载与安装**:首先,你需要从Jenkins官方网站(https://jenkins.io/)下载适合你操作系统的Jenkins war文件。将其放在服务器或本地的Tomcat等应用服务器的webapps目录下。 2. **启动Jenkins**:通过命令行或...
用户可以通过在命令行中使用`java -jar jenkins.war`启动Jenkins,然后通过默认端口8080访问其管理界面。 2. Jenkins插件管理: Jenkins的强大在于它的可扩展性,通过安装各种插件,可以支持多种构建、测试和部署...
3. **PATH**:需要将Jenkins可执行文件的路径添加到系统PATH环境变量中,这样可以在命令行中直接启动Jenkins。 4. **启动Jenkins**:在环境变量配置完成后,可以通过执行`jenkins.war`(如果提供的是一个war包)...
**症状**:当 Jenkins 安装在 Linux 服务器上时,默认情况下只有 root 用户有权限进行文件操作。 **解决方法**: - 将 Jenkins 用户添加到具有足够权限的用户组。 - 修改 Jenkins 目录的所有权和权限,使其能够正常...
在命令行中,你可以使用 `service jenkins restart`(Linux)或 `net stop jenkins` 和 `net start jenkins`(Windows)命令来实现。 6. **验证安装**:启动 Jenkins 后,登录管理界面,进入“系统管理”->“插件...
### Jenkins配置文档知识点详解 #### 一、启动与停止Jenkins服务 在进行Jenkins的配置与使用过程中,启动和停止服务是基本的操作之一。以下为具体的命令介绍: 1. **启动Jenkins服务**: - 命令格式: ``` ...
Jenkins通常以WAR文件的形式提供,可以将其放在你选择的目录(例如D:\jenkins),然后在命令行中运行`java -jar jenkins.war`启动服务。当Jenkins显示"fully up and running"时,表示安装成功。你可以通过访问`...
7. **Jenkins配置文件**:在提供的压缩包中,可能包含了Jenkins的配置文件,这些文件可以帮助快速复现和调整打包流程。通常,这些文件是XML格式的,如`config.xml`,可以直接导入Jenkins中。 8. **优化与扩展**:...
- **通过命令行安装**:可以使用`jenkins-cli.jar`工具,通过`install-plugin`命令来安装插件。例如: ``` java -jar jenkins-cli.jar -s http://your-jenkins-url install-plugin plugin-name ``` - **手动安装...
- **批量安装**:如果你有很多插件需要安装,可以创建一个文本文件,每行包含一个插件的.hpi文件路径,然后通过Jenkins管理界面的命令行接口执行批量安装。 4. **检查兼容性**:描述中提到部分插件可能较旧,因此...
Jenkins X的主要特色在于其方便使用的命令行工具jx,该工具简化了Kubernetes集群中Jenkins X的安装过程,允许开发者通过简单的命令完成Jenkins X的部署,并且支持在现有的Kubernetes集群上安装Jenkins X,或创建一个...
用于解密和转储Jenkins凭证的命令行工具。 这是怎么回事 Jenkins将加密的凭据存储在credentials.xml文件或文件夹下的config.xml 。 要解密它们,您需要master.key和hudson.util.Secret文件。 所有文件都位于Jenkins...