jenkinsapi icon indicating copy to clipboard operation
jenkinsapi copied to clipboard

Add CredentialsById.update to create/update credential by id

Open kkpattern opened this issue 4 years ago • 0 comments

There are two cases where creating/updating credential by id is needed:

  1. The credential id is needed in the pipeline script.
  2. 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)

kkpattern avatar Jan 15 '21 12:01 kkpattern