Naveen Balaneni
Naveen Balaneni

Reputation: 11

Jenkins-CLI/Rest API to change the credentials in the created Jenkins Job

I am creating a Jenkins Job using the Jenkins CLI/REST API, by copying Jenkins Job template, I am good with this.

Now I need to change the credentials in newly created Jenkins Job(like GIT Credentials, Artifactory, Docker), the created Jenkins Job have someones credentials, i need mine there)

Is there any API/provision to do this?

Upvotes: 0

Views: 1070

Answers (1)

Naveen Balaneni
Naveen Balaneni

Reputation: 11

Below jenkins Rest API is used to add the credentials to the user

curl --user username:password -XGET 'http://localhost:8080/credentials/store/system/domain/_/createCredentials' --data-urlencode 'json={ "": "0", "credentials": { "scope": "GLOBAL", "id": "apicredentials", "username": "username", "password": "password", "description": "apicredentials", "stapler-class": "com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl" } }'

Once you add the credentials to the jenkins, change the cloned xml with the latest username and ID, and push the updated xml to create new jenkins job.

Upvotes: 1

Related Questions