gpt4 book ai didi

azure-devops - Azure 管道 : Accessing network drives on self-hosted Windows agent?

转载 作者:行者123 更新时间:2023-12-05 05:01:14 24 4
gpt4 key购买 nike

我有一台带有自托管 Azure Pipeline 代理的本地 Windows 计算机,我想在该计算机上运行一些需要访问存储在网络驱动器上的文件的脚本。但是,当我收到“找不到路径”或类似错误时,它们似乎无法访问。在 Powershell 中运行 net use 会返回我想要访问的网络驱动器列表,但它们的状态设置为“不可用”。

我怀疑这与身份验证有关,但我不确定如何解决。我应该注意,我没有管理员权限,但我的用户确实可以正常访问驱动器,并且代理是使用我的用户名配置的。

最佳答案

Azure Pipelines: Accessing network drives on self-hosted Windows agent?

当您执行构建时,所有构建任务都应在您的构建服务帐户下运行,例如 AzuredevopsAccount1

因此,您需要确保构建服务帐户是否具有访问网络驱动器的权限。

此外,如果您有访问网络驱动器的用户名和密码,我们可以尝试使用它来访问网络驱动器。

例如,我使用 powershell 脚本复制带有提供给网络驱动器的特定用户名和密码的源文件:

$Source = $env:BUILD_SOURCESDIRECTORY
$Dest = "\\172.17.xx.xx\SourceFiles\xxx"
$Username = "domain\username"
$Password = ConvertTo-SecureString "PasswordHere" -AsPlainText -Force
$mycreds = New-Object System.Management.Automation.PSCredential($Username, $Password)
New-PSDrive -Name J -PSProvider FileSystem -Root $Dest -Credential $mycreds -Persist
Copy-Item -Path $Source -Recurse -Force -Destination $Dest

测试结果:

enter image description here

希望这对您有所帮助。

关于azure-devops - Azure 管道 : Accessing network drives on self-hosted Windows agent?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62791820/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com