Multi line cmd or powershell warning ignore ?
Hi,
I have a project with different jobs, and for more readability, I want to cut my 1000chars + lines into multiple lines.
So here is what I came to :
build_script:
- ps: >-
If ($env:platform -Match "msvc") {
& msvc.bat
} ElseIf ($env:platform -Match "mingw32") {
$env:PATH = "xxx;$env:PATH"
cmd1
cmd2
...
cmd99
}
The problem is that when any of my command generate a warning on stderr (which happens often in a Debug build, and which is not always threatening the project health state), the build fails -- I found out that it is because of powershell receiving something on its stderr.
Now, one of the answer I found on this forum is to "use cmd". Ok so let's translate my code like this:
build_script:
- cmd: >-
if %platform% == msvc )
msvc.bat
) else (
set PATH = "xxx;%PATH%"
cmd1
cmd2
...
cmd99
)
But no, it just does not work, because (apparently) the cmd command does not support the if statement over multiple lines. It's multi line, but still one line at a time.Of course, the working way would be to have something like this:
build_script:
- cmd: if %platform% == msvc ( msvc.bat ) else ( cmd1 && cmd2 && cmd3 && cmd4 && cmd5 && cmd6 && cmd7 && cmd8 && cmd9 && cmd10 && cmd11 && cmd12 && cmd13 && cmd14 && cmd15 && cmd16 && cmd17 && cmd18 && cmd19 && cmd20 && cmd 21 && cmd 22 && cmd 23 && cmd 24 && ... && cmd99 )
This is so dirty and so hard to maintain that I do hope any of you have a good alternative to solve my problem ! (either ignore warnings with powershell, or use multiple lines with the cmd directive.I hope my problem is clear enough, and thank you in advance
Comments are currently closed for this discussion. You can start a new one.
Keyboard shortcuts
Generic
| ? | Show this help |
|---|---|
| ESC | Blurs the current field |
Comment Form
| r | Focus the comment reply box |
|---|---|
| ^ + ↩ | Submit the comment |
You can use Command ⌘ instead of Control ^ on Mac

1 Posted by Ilya Finkelshte... on 12 May, 2017 01:10 PM
You can use tweak/hack from our previous conversation like this:
and keep all multi-line script in.batfiles instead of YAML... Also no need to if/else with this approach.2 Posted by xarkes on 12 May, 2017 02:48 PM
Could you please paste an example with multiple commands ?
Which does not really do what I wanted in a first place ?From what you show me, I think that I will have something like this in the end.
Support Staff 3 Posted by Feodor Fitsner on 12 May, 2017 05:48 PM
Ilya meant you have to put your commands to a separate
my_build_commands.cmdfile, commit thatmy_build_commands.cmdfile into repository and then use fromappveyor.yml:4 Posted by xarkes on 12 May, 2017 06:03 PM
Ok that's what I was thinking, thanks for precising :)
Ilya Finkelshteyn closed this discussion on 25 Aug, 2018 02:17 AM.