Before_script scripting environment/language

Im running a before_script to load all env variables into a .env file for each os. My script is this:

before_script:
  - cp public/.env.example public/.env
  - |
    if [ "$TRAVIS_OS_NAME" == "windows" ];
    then get-content public/.env | %{$_ -replace $_,"$($_)$(Get-Variable -Name $_.TrimEnd("="))"};
    else printenv > public/.env;
    fi

The problem is that the command for windows runs correctly on my local powershell but when the script runs on the windows vm on travis it exits with error codes:

/c/Users/travis/.travis/functions: line 110: get-content: command not found
/c/Users/travis/.travis/functions: command substitution: line 111: syntax error near unexpected token `('
/c/Users/travis/.travis/functions: command substitution: line 111: `Get-Variable -Name $_.TrimEnd("="))"}'

I’m not sure if the before_script is running inside the vm(windows) or inside a host(bash?). It is not clear in the docs what scripting language is used in the before_script, etc lifecycles. Could you please provide more information?

Your script will run with git bash, as explained in


not Power Shell.

Thanks, sorry for not seeing that!

No worries!

Imprint