[英]Artifactory restore nuget packages with authentication from powershell
Our team started using Artifactory a few weeks ago and one of the challenges we are currently trying to work through is authentication. 我们的团队几周前开始使用Artifactory,我们目前正在努力解决的挑战之一就是身份验证。 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. 当前,我们在Artifactory中具有使用帐户登录名进行的每个开发人员设置,我们具有一个build.ps1文件,该文件用于还原nuget程序包,但我们正在尝试使该过程自动化。
Here is what our powershell script looks like. 这是我们的powershell脚本的样子。 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. 但是,它不会提示用户输入用户名和密码,除非他们将其作为参数添加到。\\ build.ps1命令行中,但是存在的问题是密码是以纯文本形式输入的。
"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 在Windows PowerShell中使用密码,安全字符串和凭据
I had some problems with setting the credentials. 我在设置凭据时遇到了一些问题。
My solutions was to upgrade nuget.exe (v4.3.0 from v3.xx) and using the Add Sources with the username/ password, with the ApiKey from the Artifactory as the password. 我的解决方案是升级nuget.exe(从v3.xx升级到v4.3.0),并使用带有用户名/密码的添加源,并使用来自Artifactory的ApiKey作为密码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.