使用 api 下载 TFS 构建工件 returns 401 授权错误
Download TFS build artifact using api returns 401 Authorized error
我正在尝试通过 Powershell 脚本使用 REST API 下载 TFS 构建工件。我收到 401 授权错误。有什么我遗漏的吗?
invoke-webrequest -uri "https://collectionurl/tfs/DefaultCollection/_apis/build/builds/33002/artifacts?artifactName=drop&api-version=2.0&%24format=zip" -OutFile "C:\Temp\drop.zip" -UseDefaultCredentials
也尝试通过浏览器,不断弹出凭据。我验证了我的帐户访问权限,一切似乎都很完美。
我有本地 TFS 2018。
我采用了不同的方法来下载神器。但是,如果有人能够找到上述问题的解决方案,我们将不胜感激。
我在下面使用 API 下载工件(发现我们也可以下载单个文件)。能够通过 GET 构建详细信息检索容器 ID。
https://collectionurl/tfs/defaultcollection/_apis/resources/Containers/${containerid}?itempath=drop
您的 API 看起来不错,似乎只是调用了整个 drop 文件夹的下载 url。就像这张票:How to get the download url of the artifact in Visual Studio Team Services?
根据您的描述,即使通过浏览器,它仍然会不断弹出凭据。
如果是这样,您的问题可能与凭据缓存有关。尝试清除存储在 Control Pane--Credential Manager.
中的所有 TFS 凭据缓存
此外,除了使用account/password,您还可以尝试使用PAT。用户名应为空白。 PAT是密码。
由于您将 PAT 与本地 TFS 服务器一起使用,请检查您是否已经关闭了基本身份验证。
We recommend you keep IIS Basic Authentication turned off at all times
when using Azure DevOps Server. Only if necessary should you enable
IIS Basic Authentication. When IIS Basic Authentication is enabled on
your windows machine, it prevents you from using personal access
tokens (PATs) as an authentication mechanism.
关于如何使用powershell下载build artifacts的更多细节,你也可以看看这个博客--Downloading Build Artifacts in TFS Build
我正在尝试通过 Powershell 脚本使用 REST API 下载 TFS 构建工件。我收到 401 授权错误。有什么我遗漏的吗?
invoke-webrequest -uri "https://collectionurl/tfs/DefaultCollection/_apis/build/builds/33002/artifacts?artifactName=drop&api-version=2.0&%24format=zip" -OutFile "C:\Temp\drop.zip" -UseDefaultCredentials
也尝试通过浏览器,不断弹出凭据。我验证了我的帐户访问权限,一切似乎都很完美。
我有本地 TFS 2018。
我采用了不同的方法来下载神器。但是,如果有人能够找到上述问题的解决方案,我们将不胜感激。
我在下面使用 API 下载工件(发现我们也可以下载单个文件)。能够通过 GET 构建详细信息检索容器 ID。
https://collectionurl/tfs/defaultcollection/_apis/resources/Containers/${containerid}?itempath=drop
您的 API 看起来不错,似乎只是调用了整个 drop 文件夹的下载 url。就像这张票:How to get the download url of the artifact in Visual Studio Team Services?
根据您的描述,即使通过浏览器,它仍然会不断弹出凭据。
如果是这样,您的问题可能与凭据缓存有关。尝试清除存储在 Control Pane--Credential Manager.
中的所有 TFS 凭据缓存此外,除了使用account/password,您还可以尝试使用PAT。用户名应为空白。 PAT是密码。
由于您将 PAT 与本地 TFS 服务器一起使用,请检查您是否已经关闭了基本身份验证。
We recommend you keep IIS Basic Authentication turned off at all times when using Azure DevOps Server. Only if necessary should you enable IIS Basic Authentication. When IIS Basic Authentication is enabled on your windows machine, it prevents you from using personal access tokens (PATs) as an authentication mechanism.
关于如何使用powershell下载build artifacts的更多细节,你也可以看看这个博客--Downloading Build Artifacts in TFS Build