2016-12-02 152 views
0

我使用Jenkins版本2.7.20(安裝在某些Linux機器上)。 我想刪除一個用戶使用我的Windows機器(這是在同一網絡)的一些API。Jenkins:使用api刪除用戶

我試過這個命令來獲取證書的詳細信息我的用戶user1

E:\>java -jar jenkins-cli.jar -s http://myjenkinsserver:6060 get-credentials-as-xml "user1" --username "adminUserID" --password "adminPasswd" 

但我得到這個錯誤:

ERROR: Malformed store identifier, expecting Provider::Resolver::ContextPath got 
user1 
java -jar jenkins-cli.jar get-credentials-as-xml STORE DOMAIN CREDENTIAL [--user 
name VAL] [--password VAL] [--password-file VAL] 
Get a Credentials as XML (secrets redacted) 
STORE    : Store Id 
DOMAIN    : Domain Name 
CREDENTIAL   : Credential Id 
--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 
  1. 我如何獲得Store IdDomain Nameuser1
  2. 如何在Jenkins安裝上找到我的密碼文件路徑?

我試圖刪除使用的憑據:

E:\> java -jar jenkins-cli.jar -s http://myjenkinsserver:6060 delete-credentials "user1" --username "adminUserID" --password "adminPasswd" 

但我已經得到了同樣的錯誤。

回答

1

沒有試過這個。要檢索證書編號:

例子:

java -jar /usr/bin/jenkins-cli.jar -s http://127.0.0.1:8080 -i /keys_path/.ssh/id_rsa list-credentials system::system::jenkins

這會給你的輸出看起來像這樣:

https://gist.github.com/michaelBenin/59ffbf20c87000bb4b2ac88652a70951

從那裏,你應該有訪問ID 。

使用該ID,您現在可以訪問XML它,像這樣:

java -jar /usr/bin/jenkins-cli.jar -s http://127.0.0.1:8080 -i /keys_path/.ssh/id_rsa get-credentials-as-xml system::system::jenkins _ someid

我會假設你就可以做同樣的刪除憑據:

java -jar /usr/bin/jenkins-cli.jar -s http://127.0.0.1:8080 -i /keys_path/.ssh/id_rsa delete-credentials system::system::jenkins _ someid

來源:https://groups.google.com/forum/#!topic/jenkinsci-users/YR-ba25BFZw