Can I use bash commands in the YML for Windows?

Oliver Collyer's Avatar

Oliver Collyer

05 Mar, 2020 08:30 PM

I can't find a clear indication as to whether this *should* work or not?

Currently, by default commands are interpreted for a Windows image as CMD.

Putting sh: before the command, then leads to it being ignored.

Is that just something that isn't supported? To tailor AppVeyor to my needs I am making use of various bash commands, it's annoying to have ti duplicate all of this for batch.

I've installed WSL on my Windows machine, typing bash.exe from command prompt brings up the bash prompt.

  1. 1 Posted by Oliver Collyer on 07 Mar, 2020 10:14 AM

    Oliver Collyer's Avatar

    So I figured out how to make it work, but I would like to request that "sh:" be made a valid option for a Windows image.

    • bash -c "echo this is bash"

    But this doesn't:

    • sh: echo this is bash

    Also, it only seems to work with Git bash and not the Windows Subsystem for Linux. For example, the following command fails with an error code of -1, for reasons I can't work out:

    wsl -- echo this is bash

    Likewise, if you configure the Windows machine to have Ubuntu installed and for "bash.exe" to path to the Ubuntu one, then again it fails with error -1.

    This is all on Windows 10.

    So my feature request is to make "sh:" work for Windows, so we don't have to have the ugly bash -c "blah" syntax, and secondly can it be made to work for WSL/Ubuntu bash etc too?

  2. 2 Posted by Eugen on 01 Apr, 2020 01:02 PM

    Eugen's Avatar

    Same issue here, i would need to run the command in WSL bash like in azure pipelines.

    I'am not sure i understand your workarround

    install:
    - sh: bash -c "./build/conan/install.sh"
    

    Is this supposed to work then?

  3. 3 Posted by Oliver Collyer on 01 Apr, 2020 01:14 PM

    Oliver Collyer's Avatar

    Not quite - you are running bash.exe as a ommand so you need to drop the sh: or replace it with a cmd:

    I have this working nicely but you need to make sure that bash.exe is the one supplied with Windows git and not the one that is part of the Windows linux subsystem, as I found the latter did not work with Appveyor.

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

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

Recent Discussions

27 Jan, 2023 08:06 PM
27 Jan, 2023 08:05 PM
25 Jan, 2023 03:23 PM
25 Jan, 2023 03:22 PM
23 Jan, 2023 03:29 PM