下载了内置命令行界面的jenkins jenkins-cli.jar文件之后,我在网上找到的教程提示我在命令提示符下执行以下命令以运行它:
java -jar jenkins-cli.jar -s http://localhost:8080/ help
但是当我输入此命令时,会返回以下错误:
错误:无法访问jarfile jenkins-cli.jar
我不知道为什么会这样。可以使用Windows机器与我联系吗?任何关于为什么会发生这种情况以及最终如何运行的提示都将受到赞赏。提前谢谢!
答案 0 :(得分:1)
https://jenkins.io/doc/book/managing/cli/
指HTTP连接模式
身份验证最好使用-auth选项,该选项采用用户名:apitoken参数。从/ me / configure获取您的API令牌:
**java -jar jenkins-cli.jar [-s JENKINS_URL] -auth kohsuke:abc1234ffe4a command ...**
(也接受实际密码,但不鼓励这样做。)
您也可以在参数前加上@来从文件中加载相同的内容:
<强> java -jar jenkins-cli.jar [-s JENKINS_URL] -auth @/home/kohsuke/.jenkins-cli command ...
强>
通常,不需要执行特殊的系统配置来启用基于HTTP的CLI连接。如果您在HTTP(S)反向代理后面运行Jenkins,请确保它不会缓冲请求或响应主体。
答案 1 :(得分:1)
此消息仅表示jenkins-cli.jar不在$ PATH中,也不在运行java的同一目录中。
这里,jenkins-cli.jar文件位于我的$ HOME / bin目录中。起初我尝试从$ HOME
运行它➜ ~ java -jar jenkins-cli.jar
Error: Unable to access jarfile jenkins-cli.jar
现在来自$ HOME / bin
➜ ~ cd bin
➜ ~/bin ls -al jenkins-cli.jar
-rw-rw-r-- 1 user user 2849829 juin 23 10:04 jenkins-cli.jar
➜ ~/bin java -jar jenkins-cli.jar
Neither -s nor the JENKINS_URL env var is specified.
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 and -remoting)
-ssh : use SSH protocol (requires -user; SSH port must be open on server, and user must have registered a public key)
-remoting : use deprecated Remoting channel protocol (if enabled on server; for compatibility with legacy commands or command modes only)
-i KEY : SSH private key file used for authentication (for use with -ssh or -remoting)
-p HOST:PORT : HTTP proxy host and port for HTTPS proxy tunneling. See https://jenkins.io/redirect/cli-https-proxy-tunnel
-noCertificateCheck : bypass HTTPS certificate check entirely. Use with caution
-noKeyAuth : dont 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, or -remoting but only when the JNLP agent port is disabled
The available commands depend on the server. Run the help command to
see the list.
答案 2 :(得分:0)
在这种情况下,(我认为)它与连接本身无关,但与jar文件位于同一文件夹中。
如果无法访问jar文件,则执行java -jar ...
命令时,您可能与jar文件不在同一个目录中。
启动终端,然后将Director(cd <folder>
)更改为您下载jar文件的位置,然后重试。