【问题标题】:Team Get-Item env:$variable doesnt work in all buildsTeam Get-Item env:$variable 不适用于所有版本
【发布时间】:2018-08-21 04:47:32
【问题描述】:

我已经能够通过在 Teamcity 中的一个构建配置中使用 Get-Item 命令获得 env:$var,但在另一个构建配置中却失败了。当我打印这些值时,我能够得到结果,但是当我使用 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 中声明参数,但没有帮助。

【问题讨论】:

    标签: powershell environment-variables teamcity


    【解决方案1】:

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

    【讨论】:

    • 感谢您的回复,但它不是文件夹,它是我试图读取其值的变量。
    • 据我了解 env:$var 包含 TestDeploy_GhNew.promote.from.envGet-ChildItem 无法读取此文件夹。测试:Get-ChildItem $env:CommonProgramFiles.
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-06-05
    • 1970-01-01
    • 1970-01-01
    • 2012-12-09
    • 1970-01-01
    相关资源
    最近更新 更多