问题描述
我需要创建一个詹金斯凭证( https://wiki.jenkins-ci.org/display /JENKINS/Credentials + Plugin )通过脚本.如何使用REST API或cli做到这一点?
I need to create a jenkins credential ( https://wiki.jenkins-ci.org/display/JENKINS/Credentials+Plugin ) via a script. How can I do that using either the REST API or the cli ?
请注意,我能够使用/credential-store/domain//api/json和/credential-store/domain//credential/8bd82461-e239-4db1-90bc列出凭据-831ca3412e70/api/json等
Note that I'm able to list the credentials using /credential-store/domain//api/json and /credential-store/domain//credential/8bd82461-e239-4db1-90bc-831ca3412e70/api/json etc.
推荐答案
这个问题使我花了一段时间才能弄清楚,进行了很多挖掘,因此,如果有人需要,我决定将解决方案留在这里.
This issue took me a while to figure, a lot of digging around, so I decided to let the solution here, if someone else needs it.
curl -X POST 'http://user:token@jenkins_server:8080/credentials/store/system/domain/_/createCredentials' \
--data-urlencode 'json={
"": "0",
"credentials": {
"scope": "GLOBAL",
"id": "identification",
"username": "manu",
"password": "bar",
"description": "linda",
"$class": "com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl"
}
}'
这篇关于如何通过REST API创建jenkins凭证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!