团队Get-Item env:$ variable在所有构建中都不起作用

时间:2018-03-13 02:50:05

标签: powershell environment-variables teamcity

我在一个构建配置中通过在Teamcity中使用env:$var命令获得Get-Item,但在另一个构建配置中失败了。当我打印值时,我能够得到结果,但是当我使用Get-childitem env:$var时,它失败并出现以下错误:

Get-childitem : Cannot find path 'TestDeploy_GhNew.promote.from.env' because 
[19:34:32][Step 2/4] it does not exist.
[19:34:32][Step 2/4] At C:\BuildAgent\work\4aa6addd2114a494\deploy\foo.ps1:23 char:29
[19:34:33][Step 2/4] +                     $var = (Get-childitem env:$env_var).value
[19:34:33][Step 2/4] +                             ~~~~~~~~~~~~~~~~~~~~~~~~~~
[19:34:33][Step 2/4]     + CategoryInfo          : ObjectNotFound: (TestDeploy_GhNew.promote.from.e 
[19:34:33][Step 2/4]    nv:String) [Get-ChildItem], ItemNotFoundException
[19:34:33][Step 2/4]     + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetCh 
[19:34:33][Step 2/4]    ildItemCommand

我已尝试在脚本窗口中声明参数Get-Item env:$var,但没有帮助。

1 个答案:

答案 0 :(得分:0)

根据错误您可以阅读env:$var,但它指向的文件夹('TestDeploy_GhNew.promote.from.env')不存在。