Enable PowerShell Core support in Shell Executor
Description
Enable PowerShell 6 Core support in the Shell Exeuctor
Proposal
In #3291 (closed) we evaluated the feasibility of including Powershell Core 6 to the Runner executors. There is now an open !2199 (merged) that will enable this capability.
- Allow user to specify
pwsh
as a shell, which will use thepowershell
shell writer, but instead of invokingpowershell
invokepwsh
. Something similar to what we do inbash
andsh
just no fallback. There is WIP merge request !1855 (closed). The reason for having a new shell the user has to configured instead of just usingpowershell
is because if we makepowershell
just use PowerShell 6/7 out of the box if its available we are going to end up breaking existing scripts for users that expect to use PowerShell 5, like this users need to be aware of the change they make. -
pwsh
accepts both/
and\
in the path for Unix based systems, butgit
doesn't accept them. When we use the powershell script generator we use\
since that is the acceptable version for Windows. This leads to problems like this fails CI job. In !1855 (diffs) we extend the Extend the ShellWriter interface and implement aJoin
function to extend the which will set the correct slash depending on script type and call it instead ofpath.Join
. Another way to do this is don't covert to backslash ifpwsh
is chosen. - We use
$env:computername
to print out the first line of the jobRunning on ...
,$env:computername
doesn't seem available on Unix pwsh, so have some kind of fallback environment such ashostname
.- Pedro: We can probably replace with
[Environment]::MachineName
.
- Pedro: We can probably replace with
- When
pwsh
is choosen, set theErrorActionPreference
toStop
to prevent problems like #3194 for PowerShell 7 - Add Powershell Core to CI Docker image, so that Powershell tests can be run against
pwsh
shell as well
Links to related issues and merge requests / references
Edited by Pedro Pombeiro