Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从TeamCity使用REST下载工件_Rest_Powershell_Teamcity_Powershell 4.0 - Fatal编程技术网

从TeamCity使用REST下载工件

从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

使用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 = '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>