| How do I use the Jenkins CLI commands for Credentials Plugin? | Vishwanath V | 8/6/16 12:32 AM | Hi all, I need to automatedly load sets of credentials to a Jenkins instance, so that my jobs can pick up these credentials. For this purpose I am using the Jenkins CLI, specifically the set of commands provided by the Credentials Provider plugin: create-credentials-by-xml Create Credential by XML create-credentials-domain-by-xml Create Credentials Domain by XML get-credentials-as-xml Get a Credentials as XML (secrets redacted) get-credentials-domain-as-xml Get a Credentials Domain as XML list-credentials Lists the Credentials in a specific Store list-credentials-context-resolvers List Credentials Context Resolvers list-credentials-providers List Credentials Providers update-credentials-by-xml Update Credentials by XML update-credentials-domain-by-xml Update Credentials Domain by XML I am trying to understand how to use them, but there is literally no documentation on this beyond the actual code (which I unfortunately am unable to understand). Question 1. What is the "Store ID"? Based on the error messages, I understand it is list-credentials [Store ID] I am unable to understand what the Store ID is. Another error message says it should be in the format Provider::Resolver::ContextPath. But where would I get this information from? Question 2: How do I load an XML for "create-credentials-by-xml"? When I use the create-credentials-by-xml, I assume I need to provide an XML file. How do I provide this ? i.e would it be as follows create-credentials-by-xml [Store ID] [Path to XML] ?? |
| Re: How do I use the Jenkins CLI commands for Credentials Plugin? | Brandon R | 8/15/16 2:12 PM | I've been looking into this as well and made a little progress by digging around https://github.com/jenkinsci/credentials-plugin For store, I used "system::system::jenkins" like in their tests. For domain I tried variations on the word "global" but none worked. I then tried underscore '_' as a wild guess and that worked. I tried that because it's in the url when you hover on (global) on the credentials page. Anyway, I haven't tried creating creds yet, but I can at least get them like: java -jar /usr/share/jenkins/jenkins-cli.jar -s http://localhost:8080 -i ~jenkins/.ssh/id_rsa list-credentials system::system::jenkins and java -jar /usr/share/jenkins/jenkins-cli.jar -s http://localhost:8080 -i ~jenkins/.ssh/id_rsa get-credentials-as-xml system::system::jenkins _ somecredname (note that I require auth hence the -i. This might not be relevant in your case) Hope this helps some. |
| Re: How do I use the Jenkins CLI commands for Credentials Plugin? | Andreas P | 9/2/16 7:22 AM | the way you load the XML is by pipeing it into the command. e.g.: it would be nice if the documentation would give hints to that. (or I didnt find them) |