jenkinsapi
jenkinsapi copied to clipboard
Add CredentialsById.update to create/update credential by id
There are two cases where creating/updating credential by id is needed:
- The credential id is needed in the pipeline script.
- The description of the credential is an empty string or conflict with another credential(often happens when there are lots of existing credentials missing description).
So I added CredentialsById.update to create/update credential by id.
Example:
jenkins = Jenkins(
jenkins_host,
username=os.environ["JENKINS_USERNAME"],
password=os.environ["JENKINS_PASSWORD"],
timeout=10)
credential = UsernamePasswordCredential({
"description": "Test credential.",
"userName": "test_user_name",
"password": "test_password",
"credential_id": "TEST_CREDENTIAL"})
jenkins.credentials_by_id.update(credential)