After some playing around, the following curl command worked for me. Per

curl -XPOST 'localhost:8080/credential-store/domain/_/createCredentials' \
    --data-urlencode 'json={
        "": "0", 
        "credentials": {
            "scope": "GLOBAL", 
            "id": "", 
            "username": "foo", 
            "password": "bar", 
            "description": "biz", 
            "$class": 
"com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl"
        }
    }'


On Sunday, December 28, 2014 at 9:01:00 PM UTC-5, [email protected] wrote:
>
> Hi, I tried the method you said, but it doesnot work
>
> post_params = {
>           "name" => "testcred",
>           "description" => "test cred description",
>           "json" => {
>             "domainCredentials" => {
>               "domain" => {
>                 "name" => "",
>                 "description" => "",
>               },
>               "credentials" => {
>                 "scope" => "GLOBAL",
>                 "id" => "",
>                 "username" => "root",
>                 "description" => "root users credential",
>                 "privateKeySource" => {
>                   "value" => "0",
>                   "privateKey" => "blah blah blah",
>                   "stapler-class" => 
> "com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey$DirectEntryPrivateKeySource"
>                 },
>                 "passphrase" => "",
>                 "stapler-class" => 
> "com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey",
>                 "kind" => 
> "com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey"
>               }
>             }
>           }.to_json
>         }
> @client.api_post_request("/credentials/configSumbit", post_params)
>
> Could you give me the example?
>
>
>
> On Tuesday, October 29, 2013 2:27:01 PM UTC+8, Kannan Manickam wrote:
>>
>> Hello,
>>
>> I am the author of the jenkins_api_client project: 
>> https://github.com/arangamani/jenkins_api_client
>>
>> I used to be able to create a dump slave using some hack I had in 
>> http://www.arangamani.net/jenkins_api_client/JenkinsApi/Client/Node.html#create_dump_slave-instance_method
>>  
>> which simply posts some JSON data to the “/computer/doCreateItem” endpoint 
>> and it used to work fine until we had the private key file as an option. 
>> Now that it got changed to use the new Credentials interface, it doesn’t 
>> work anymore. I can specify the credential ID in the JSON but I couldn’t 
>> get the credentials to work using the API.
>>
>> After some hacking, I could get the credential to create using a POST of 
>> the following JSON data to “/credentials/configSumbit”
>>
>> post_params = {
>>           "name" => "testcred",
>>           "description" => "test cred description",
>>           "json" => {
>>             "domainCredentials" => {
>>               "domain" => {
>>                 "name" => "",
>>                 "description" => "",
>>               },
>>               "credentials" => {
>>                 "scope" => "GLOBAL",
>>                 "id" => "",
>>                 "username" => "root",
>>                 "description" => "root users credential",
>>                 "privateKeySource" => {
>>                   "value" => "0",
>>                   "privateKey" => "blah blah blah",
>>                   "stapler-class" => 
>> "com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey$DirectEntryPrivateKeySource"
>>                 },
>>                 "passphrase" => "",
>>                 "stapler-class" => 
>> "com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey",
>>                 "kind" => 
>> "com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey"
>>               }
>>             }
>>           }.to_json
>>         }
>>
>> But there doesn’t seem to be a way for me to obtain the ID of the created 
>> credential so I can’t automate this process. 
>>
>> Is there support for the new credentials interface in the Remote Access 
>> API? If not will this be added in the future?
>>
>> Thanks,
>> Kannan.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-dev/d46a1bdd-703b-4dd4-bdc3-febefc55da34%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to