使用 Team City 2017.1.1(内部版本 46654)我正在尝试使用 Windows 10 上的 Powershell 中的 REST 下载工件。
我正在使用这个:https : //confluence.jetbrains.com/display/TCD10/REST+API#RESTAPI-BuildArtifacts
但我仍然无法让它工作。例如,我正在尝试从以下 URL 下载我可以使用浏览器访问的 info.txt 工件:
http://mytc/repository/download/MyBuildConfiguration/294859:id/output/logs/info.txt
基于:https : //confluence.jetbrains.com/display/TCD10/REST+API#RESTAPI-BuildArtifacts
我正在从 Powershell 执行以下操作:
$TeamCityUser = 'tcuser'
$TeamCityPassword = 'tcpass'
$securePassword = ConvertTo-SecureString $TeamCityPassword -AsPlainText -Force
$creds = New-Object System.Management.Automation.PSCredential($TeamCityUser, $securePassword)
$response = Invoke-WebRequest http://mytc/httpAuth/app/rest/builds/294859:id/artifacts/output/logs/info.txt -Credential $creds
但我收到错误:
Invoke-WebRequest : The remote server returned an error: (400) Bad Request.
根据以下建议,我现在尝试过:
$response = Invoke-WebRequest http://mytc/httpAuth/app/rest/builds/id:294859/artifacts/output/logs/info.txt -Credential $creds
但仍然得到:
Invoke-WebRequest : The remote server returned an error: (404) Not Found.
有任何想法吗?
您可以递归导航给定构建的工件:
http://mytc/httpAuth/app/rest/builds/id:294859/artifacts/并使用节点:children
响应。
响应可能是:
<files count="1">
<file name="output" modificationTime="20170724T160034+0200" href="/httpAuth/app/rest/builds/id:294859/artifacts/metadata/output">
<children href="/httpAuth/app/rest/builds/id:294859/artifacts/children/output"/>
</file>
</files>
然后,在: 上提出相同的要求children.href
,您可能有另一个孩子。(即:日志)当您到达您想要的叶项目时,而不是子节点,您将拥有一个带有您想要调用的 href 的内容节点。
<files count="1">
<file name="info.txt" size="75435" modificationTime="20170724T160034+0200" href="/httpAuth/app/rest/builds/id:3906258/artifacts/metadata/output/logs/info.txt">
<content href="/httpAuth/app/rest/builds/id:3906258/artifacts/content/output/logs/info.txt"/>
</file>
</files>
递归地使用响应将确保人工制品的路径是正确的,并且是正确的。并将确保人工制品仍然可用。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句