name=myname
user=myuser
token=mytoken
ssh_pri_key=$(cat ${PWD}/id_rsa | tr '\n' '&' | sed 's/&$//g' | sed 's/\&/\\n/g')
CRUMB=$(curl -s "https://${user}:${token}@jenkins/crumbIssuer/api/xml?xpath=concat(//crumbRequestField,\":\",//crumb)")
curl -i -H "${CRUMB}" -X POST "https://${user}:${token}@jenkins/credentials/store/system/domain/_/createCredentials" \
--data-urlencode "json={ \"credentials\": { \"stapler-class\":\"com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey\", \"scope\":\"GLOBAL\", \"username\":\"git\", \"privateKeySource\":{ \"value\":\"0\", \"privateKey\": \"${ssh_pri_key}\", \"stapler-class\":\"com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey$DirectEntryPrivateKeySource\" }, \"id\":\"${name}-deploy-key\", \"description\":\"${name}-deploy-key\", \"Jenkins-Crumb\":\"$(echo ${CRUMB} | cut -d ':' -f2)\" }}"
Caused: java.lang.IllegalArgumentException: Failed to convert the privateKeySource parameter of the constructor public com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey(com.cloudbees.plugins.credentials.CredentialsScope,java.lang.String,java.lang.String,com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey$PrivateKeySource,java.lang.String,java.lang.String)
Personally for that task I've used the CLI functionality to run a Groovy script to setup credentials. Don't know if that's an option for you or not.
Richard.
--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/aff88570-6692-4987-b9ff-bf65c1bedfda%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAMui945zDxZc9k8X0O_TSi07u%2BQAPnDq%2B0Fb-6%3DiMcQ%3Ddftsxg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/aff88570-6692-4987-b9ff-bf65c1bedfda%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAMui945zDxZc9k8X0O_TSi07u%2BQAPnDq%2B0Fb-6%3DiMcQ%3Ddftsxg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.