I'm using Powershell DSC to set up a Windows Server 2012 R2 box. As part of the configuration process, I'm provisioning jfrog.exe and executing a configuration command as a service account:
jfrog rt config --url=$localArtifactoryInstance --user=$username --apikey=$apikey
This command creates .jfrog.jfrog-cli.conf in the service account's home directory (C:\\Users\\$serviceAccount.jfrog.jfrog-cli.conf) as expected, containing URL/username/apiKey.
Post-provisioning, this service account is charged with 'promoting' artifacts from one repository to another:
jfrog rt move '$devRepo/(Org)/(Org.Common.Configuration)/Org.Common.Configuration.1.0.0.nupkg' '$prodRepo/{1}/{2}/'
This command is rejected with a 401:
[Error] Artifactory response: 401 Unauthorized
{
"errors": [
{
"status": 401,
"message": "Bad authentication. Provided username or password are incorrect."
}
]
}
However, when I add the same API key as is already configured in jfrog-cli.conf to the command:
jfrog rt move '$devRepo/(Org)/(Org.Common.Configuration)/Org.Common.Configuration.1.0.0.nupkg' '$prodRepo/{1}/{2}/' --ApiKey $apiKey
It is successful, and I can verify success via the Artifactory UI.
Thanks for any help or guidance you can supply!
The '401 Unauthorized' response is a consequence of configuring both a username and an API key.
When running jfrog rt config
, you may supply either a username/password pair or an API key. After configuring a username and api key, my commands failed since jfrog.exe was contacting the server with a username and no password.
The solution was to remove username from my Powershell DSC config entirely, and provide only url and apikey when running jfrog rt config
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.