从TeamCity使用REST下载工件
使用Team City 2017.1.1(build 46654),我尝试在windows 10上使用REST从Powershell下载工件 我用的是: 但我还是不能让它工作。例如,我尝试从以下URL下载可以使用浏览器访问的info.txt工件:从TeamCity使用REST下载工件,rest,powershell,teamcity,powershell-4.0,Rest,Powershell,Teamcity,Powershell 4.0,使用Team City 2017.1.1(build 46654),我尝试在windows 10上使用REST从Powershell下载工件 我用的是: 但我还是不能让它工作。例如,我尝试从以下URL下载可以使用浏览器访问的info.txt工件: http://mytc/repository/download/MyBuildConfiguration/294859:id/output/logs/info.txt 基于: 我正在Powershell中执行以下操作: $TeamCityUser
http://mytc/repository/download/MyBuildConfiguration/294859:id/output/logs/info.txt
基于:
我正在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.
有什么想法吗?根据文档,您需要更改ID格式并在URL中添加/content/,替换 与
您可以递归导航给定生成的工件: 并使用响应的节点:
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>
递归地使用响应将确保人工制品的路径是正确的,并且符合实际情况。并且将确保工件仍然可用。您看到答案了吗?我使用了下面的URL,其中jar/arm.jar是工件路径,您还应该在URL中添加“/content/”
<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>