如何通过REST API更新jenkins凭证? [英] How to update jenkins credentials via the REST API?

查看:173
本文介绍了如何通过REST API更新jenkins凭证?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现这是使用REST API调用在Jenkins中创建凭据的方法,如何使用REST API调用更新具有给定ID的凭据?

I found this to create credentials in Jenkins using a REST API call, how to update the credentials with a given id using the REST API calls?

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"
  }
}'

推荐答案

带有xml文件的示例:

Example with xml file:

$ 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'

这篇关于如何通过REST API更新jenkins凭证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆