Jenkins 用户的 Jenkins CLI 设置 - 方法

aru*_*unp 2 shell jenkins jenkins-cli

我在 redhat 服务器上运行 Jenkins 1.647。我尝试根据参数在执行 Shell 中使用 Jenkins 作业从命令行创建作业。我尝试如下,但没有一个命令起作用。我的jenkins认证是基于ldap的。

通过 Jenkins 执行 Shell 执行这些命令。命令-1

java -jar jenkins-cli.jar -s https://buildserver:8080/jenkins/ get-job job-template -i /var/lib/jenkins/.ssh/id_rsa
[WARN] Failed to authenticate with your SSH keys. Proceeding as anonymous
No such job 'job-template'
java -jar jenkins-cli.jar get-job JOB [--username VAL] [--password VAL] [--password-file VAL]
Dumps the job definition XML to stdout.
 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
Build step 'Execute shell' marked build as failure
Run Code Online (Sandbox Code Playgroud)

命令2

java -jar jenkins-cli.jar -s http://buildserver:8080/jenkins/ --username my-name --password-file /tmp/password-file

/tmp/password-file
xxxxx
Run Code Online (Sandbox Code Playgroud)

有没有办法使用 Jenkins 用户 API 令牌使上述命令起作用。请建议。

Kri*_*day 5

使用

java -jar jenkins-cli.jar -s https://buildserver:8080/jenkins/ -auth USER:TOKEN get-job job-template
Run Code Online (Sandbox Code Playgroud)

您需要在下面创建一个 API 令牌JENKINS_URL:PORT/user/YOUR_USER/configure