Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I have an appveyor.yml definition which contains the fragment

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

When later trying to access %LABEL%, on non-tag commits it contains the plain string "Tag". I expected it to contain the string "nontaglabel".

On tag commits, it contains the expected string Tag with the tag name as a suffix.

How can I assign the environment variable "nontaglabel" to the environment variable on commits that aren't tags?

like image 527
Martijn Avatar asked Nov 29 '16 16:11

Martijn


1 Answers

This is because $Env:APPVEYOR_REPO_TAG has string value of "false" on non-tag commits. Thus ($Env:APPVEYOR_REPO_TAG) is evaluated to true as string value is not null or empty. Please use ($Env:APPVEYOR_REPO_TAG -eq $true) or ($Env:APPVEYOR_REPO_TAG -eq "true") -- both will work.

like image 166
Ilya Finkelsheyn Avatar answered Nov 20 '22 22:11

Ilya Finkelsheyn