I’m using a GitLab Windows runner for building my application and ssh deploying it to a Windows machine.
.gitlab-ci.yml starts a powershell script, the powershell script opens an shh connection to a machine.
If I start the script from my local machine, it works.
If I start the script from the build machine manually, it works.
But when the GitLab runner starts the script at the build machine, the error
GetConsoleMode on STD_INPUT_HANDLE failed with 6 shows up and the build flow locks. The execution neither stops, nor continues. The build will fail by timeout later.
As far as I can see, the command executes, but the ssh session doesn’t close.
I expect that there should be no difference between a manual script execution and a runner one. Is it possible to achieve?
Manual execution from build machine:
Manual execution from my local machine:
Runner execution from build machine:
- .gitlab-ci.yml file below
# .gitlab-ci.yml stages: - execute Release Runner: stage: execute script: - pwsh -File script.ps1 -login %%LOGIN%% -ip %%ADMIN%% -rsaPem %%RSAKEY%% only: - master
- script.ps1 file below
# script.ps1 param ( [parameter(mandatory=$false)] [string]$login, [parameter(mandatory=$false)] [string]$ip, [parameter(mandatory=$false)] [string]$rsaPem ) $ErrorActionPreference = "Stop" [console]::OutputEncoding = [Text.Encoding]::Utf8 $cmd = "powershell.exe -NoProfile -ExecutionPolicy ByPass -Command `"whoami`"" & ssh "$login@$ip" -n -T -i $rsaPem $cmd
- Windows runner config.toml file:
# config.toml concurrent = 1 check_interval = 0 [session_server] session_timeout = 1800 [[runners]] name = "netCore-gitlab-runner" url = "https://gitlab.site.com" token = "TOKEN" executor = "shell" shell = "powershell" [runners.custom_build_dir] [runners.cache] [runners.cache.s3] [runners.cache.gcs]