Jenkins CLI 使用记录

2022-05-17 14:59:37 浏览数 (1)

Jenkins 自带 CLI 工具

代码语言:javascript复制
Jenkins CLI
Usage: java -jar jenkins-cli.jar [-s URL] command [opts...] args...
Options:
 -s URL              : the server URL (defaults to the JENKINS_URL env var)
 -http               : use a plain CLI protocol over HTTP(S) (the default; mutually exclusive with -ssh)
 -ssh                : use SSH protocol (requires -user; SSH port must be open on server, and user must have registered a public key)
 -i KEY              : SSH private key file used for authentication (for use with -ssh)
 -noCertificateCheck : bypass HTTPS certificate check entirely. Use with caution
 -noKeyAuth          : don't try to load the SSH authentication private key. Conflicts with -i
 -user               : specify user (for use with -ssh)
 -strictHostKey      : request strict host key checking (for use with -ssh)
 -logger FINE        : enable detailed logging from the client
 -auth [ USER:SECRET | @FILE ] : specify username and either password or API token (or load from them both from a file);
                                 for use with -http.
                                 Passing credentials by file is recommended.
                                 See https://jenkins.io/redirect/cli-http-connection-mode for more info and options.

The available commands depend on the server. Run the 'help' command to see the list.
代码语言:javascript复制
Starts a build, and optionally waits for a completion.
Aside from general scripting use, this command can be
used to invoke another job from within a build of one job.
With the -s option, this command changes the exit code based on
the outcome of the build (exit code 0 indicates a success)
and interrupting the command will interrupt the job.
With the -f option, this command changes the exit code based on
the outcome of the build (exit code 0 indicates a success)
however, unlike -s, interrupting the command will not interrupt
the job (exit code 125 indicates the command was interrupted).
With the -c option, a build will only run if there has been
an SCM change.

 JOB : Name of the job to build
 -c  : Check for SCM changes before starting the build, and if there's no
       change, exit without doing a build
 -f  : Follow the build progress. Like -s only interrupts are not passed
       through to the build.
 -p  : Specify the build parameters in the key=value format.
 -s  : Wait until the completion/abortion of the command. Interrupts are passed
       through to the build.
 -v  : Prints out the console output of the build. Use with -s
 -w  : Wait until the start of the command

-c :在开始构建之前检查SCM更改,如果没有更改,退出而不进行构建 -f : 跟踪构建进度。 中断不被传递给命令 -p : 构建中在KEY=值格式中指定生成参数 -s : Wait until the completion/abortion of the command. 中断会被传递给命令 -v : 打印出构建的控制台输出。一般和 -s 或 -f 连用 -w : Wait until the start of the command

示例:

  • java -jar jenkins-cli.jar -s http://10.3.104.109:9070/ -auth root:123456 build project01 -f
  • java -jar jenkins-cli.jar -s http://10.3.104.109:9070/ -auth root:123456 build project02 -p branchs=origin/fix01 -f

0 人点赞