ARTIFACTORY: How to change the Remote Repository Password
This article outlines the steps required to successfully change the password on a remote repository in Artifactory using the REST API.
Below are the steps to change the password on a remote repository in Artifactory:
Initially, a remote generic repository was created with the username set to 'marwa' and the password set to '1234'.
To verify the repository configuration, the following command was used:
curl -uadmin -XGET "http://<Artifactory-URL>/artifactory/api/repositories/marwa-npm-remote"
The retrieved repository configuration is as follows:
{
"key" : "marwa-npm-remote",
"packageType" : "npm",
"description" : "",
"notes" : "",
"includesPattern" : "**/*",
"excludesPattern" : "",
"repoLayoutRef" : "npm-default",
"signedUrlTtl" : 90,
"enableNpmSupport" : true,
"url" : "https://registry.npmjs.org",
"username" : "marwa",
"password" : "JE2cWtVfHbG5vjybZXTs8so9f2pFkKrJbnWH7JDy6TFXjhfhnQ",
"rclass" : "remote"
}
Hence, setting the password to 1234, in the repository json, it will show as:
"password" : "JE2cWtVfHbG5vjybZXTs8so9f2pFkKrJbnWH7JDy6TFXjhfhnQ"
Then, create a JSON file named remoterepo.json with the new password:
{
"key": "marwa-npm-remote",
"username": "marwa",
"password": "12345678"
}
Now, execute the following command to update the repository configuration:
curl -uadmin -XPOST http://<Artifactory-URL>/artifactory/api/repositories/marwa-npm-remote -H "Content-Type: application/json" -T remoterepo.json
The outcome should be: "Repository marwa-npm-remote updated successfully."
Afterwards, to verify the password update, execute the following command to retrieve the repository configuration again:
curl -uadmin -XGET "http://<Artifactory-URL>/artifactory/api/repositories/marwa-npm-remote"
The retrieved repository configuration now shows the updated password:
{
"key" : "marwa-npm-remote",
"packageType" : "npm",
"description" : "",
"notes" : "",
"includesPattern" : "**/*",
"excludesPattern" : "",
"repoLayoutRef" : "npm-default",
"signedUrlTtl" : 90,
"enableNpmSupport" : true,
"url" : "https://registry.npmjs.org",
"username" : "marwa",
"password" : "JE2ghKEXx4uMHDCXkpMWeG5tohzpTmLnQeYHNrpzwXaY9KeoeE",
"rclass" : "remote"
}
Therefore, now we can see that the password in the latest GET REST API is this:
"password" : "JE2ghKEXx4uMHDCXkpMWeG5tohzpTmLnQeYHNrpzwXaY9KeoeE",
compared to the previous password which was this: "password" :
"JE2cWtVfHbG5vjybZXTs8so9f2pFkKrJbnWH7JDy6TFXjhfhnQ"
Although the actual password is not visible in the UI, the password has been successfully updated, as shown below: