gpt4 book ai didi

powershell - $Env :APPVEYOR_REPO_TAG powershell variable evaluates to true on non-tags

转载 作者:行者123 更新时间:2023-12-02 22:16:19 25 4
gpt4 key购买 nike

我有一个 appveyor.yml包含片段的定义

init:
- ps: $Env:LABEL = If ($Env:APPVEYOR_REPO_TAG) { "Tag" + $Env:APPVEYOR_REPO_TAG_NAME } else { "nontaglabel" }

稍后尝试访问 %LABEL% 时, 在非标签提交上,它包含纯字符串“标签”。我希望它包含字符串“nontaglabel”。

在标记提交时,它包含带有标记名称作为后缀的预期字符串 Tag。

如何在非标签提交时将环境变量“nontaglabel”分配给环境变量?

最佳答案

这是因为 $Env:APPVEYOR_REPO_TAG在非标记提交上具有“false”的字符串值。因此($Env:APPVEYOR_REPO_TAG)评估为 true因为字符串值不为 null 或为空。请使用 ($Env:APPVEYOR_REPO_TAG -eq $true)($Env:APPVEYOR_REPO_TAG -eq "true") - 两者都会起作用。

关于powershell - $Env :APPVEYOR_REPO_TAG powershell variable evaluates to true on non-tags,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40870786/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com