2017-07-24 39 views
1

使用Team市2017年1月1日(建46654)我想10下载文物

我用这来下载Windows上使用REST从Powershell的文物: https://confluence.jetbrains.com/display/TCD10/REST+API#RESTAPI-BuildArtifacts

但我仍然无法工作。举个例子,我想下载info.txt神器,我可以从下面的URL访问使用我的浏览器:

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. 

任何想法?

+0

你见过[this](https://stackoverflow.com/questions/14242139/how-do-i-download-a-protected-file-using-powershell)吗? – grundic

回答

1

您可以浏览一个特定的build的递归的文物:

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> 

递归地使用响应将确保工件的路径是正确的,这种情况。并确保人造物仍然可用。

0
+0

试过,同样的错误,看到更新后。 – u123

+0

我用下面的URL https://开头的TeamCity/httpAuth /应用/ REST /构建/编号:6590 /神器/内容/罐/ arm.jar 其中罐子/ arm.jar是神器路径 你还应该为网址添加“/ content /” – oryades