我发现这是使用REST API调用在Jenkins中创建凭据的方法,如何使用REST API调用更新具有给定ID的凭据?
curl -X POST 'http://jenkins:8080/credentials/store/system/domain/_/createCredentials' --data-urlencode 'json={
"": "0",
"credentials": {
"scope": "GLOBAL",
"id": "apicredentials",
"username": "apicredentials",
"password": "P@$$W0rd",
"description": "apicredentials",
"stapler-class": "com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl"
}
}'
答案 0 :(得分:0)
带有xml文件的示例:
$ cat credential.xml
<com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl>
<scope>GLOBAL</scope>
<id>apicredentials</id>
<username>manu</username>
<password>bar1</password>
</com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl>
$ curl -X POST -H content-type:application/xml -d @credential.xml 'http://USER:KEY@JENKINS_URL:8080/credentials/store/system/domain/_/credential/apicredentials/config.xml'