2017-07-24 43 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