سؤال

Our team started using Artifactory a few weeks ago and one of the challenges we are currently trying to work through is authentication. Currently we have every developer setup in Artifactory with an account login, we have a build.ps1 file that we use to restore our nuget packages but we're trying to automate this process.

Here is what our powershell script looks like. But it is not prompting the user to enter their username and password, unless they add it as parameters to the .\build.ps1 command line but the issue there is that the password is being entered in plain text.

"Updating NuGet Dependencies"
$nuget = "$rootDir\.nuget\NuGet.exe"
if ($nuser)
{
    Invoke-Expression "$nuget Sources Update -Name 'Artifactory' -UserName $user -Password $pass"
}
Invoke-Expression "$nuget install -NonInteractive -DisableParallel"
if ($lastexitcode -ne 0) {
    Write-Host -foreground red "Error occurred downloading dependencies."
    exit 1
}
dir . | where { $_.psiscontainer } | where { (test-path (join-path $_.fullname "packages.config")) } | foreach {
    Invoke-Expression "$nuget install '$($_.fullname)\packages.config' -NonInteractive -DisableParallel"
    if ($lastexitcode -ne 0) {
        Write-Host -foreground red "Error occurred downloading project dependencies."
        exit 1
    }
}
هل كانت مفيدة؟

المحلول

This article on handling passwords and credentials might prove useful to you:

Working with Passwords, Secure Strings and Credentials in Windows PowerShell

نصائح أخرى

I had some problems with setting the credentials.

My solutions was to upgrade nuget.exe (v4.3.0 from v3.x.x) and using the Add Sources with the username/ password, with the ApiKey from the Artifactory as the password.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top