Can't get basic Powershell script running inside Team City

后端 未结 3 1420
不知归路
不知归路 2020-12-16 16:05

Here\'s my configuration: \"enter

On the build log, I only see the output of the first

相关标签:
3条回答
  • 2020-12-16 16:47

    The stdin command option of Powershell has some weirdness around multiline commands like that.

    You script in the following form would work:

    write-host "test"
    write-host "test2"
    if("1" -eq "1"){write-host "test3 in if"} else {write-host "test4 in else"}
    

    The ideal way would be to use the Script : File option in TeamCity which will will run the script you specify using the -File parameter to Powershell.

    If you don't want to have a file and having VCS, in the current setup, change Script Execution Mode to Execute .ps1 file with -File argument.

    0 讨论(0)
  • 2020-12-16 16:53

    I've had this problem with inline powershell scripts with TeamCity (right up until the current version of 7.1.3). I've found the problem to be the tab character rather than multi-line statements. Try replacing the tab characters with spaces (while still remaining multi-line) and the script should run fine.

    0 讨论(0)
  • 2020-12-16 17:02

    You could try putting the brace opening the block on the same line as the If.

    I.e.,

    If ('1' -eq '1') {
        ...
    }
    Else {
        ...
    }
    

    That's the usual styling you see with Powershell, and obviously, putting the braces on the next line can cause problems.

    0 讨论(0)
提交回复
热议问题