Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to update jenkins credentials via the REST API?

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"
  }
}'
like image 609
MANU NIGOTIA Avatar asked Oct 20 '25 17:10

MANU NIGOTIA


1 Answers

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'
like image 96
Dima Kreisserman Avatar answered Oct 22 '25 12:10

Dima Kreisserman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!