'GitLab CI Runner Windows executes Powershell command differently to local Powershell

I have a Powershell command that starts a program with some arguments and waits for the execution to end. If I execute that command manually in Powershell everything works as expected. If I execute the same command through a GitLab Runner on the same machine, the process is never actually started and the CI job succeeds immediately.

The shell command:

Start-Process -Passthru -FilePath "C:\Program Files\CODESYS 3.5.17.30\CODESYS\Common\CODESYS.exe" -ArgumentList "--runscript='codesys_automation.py' --profile='CODESYS V3.5 SP17 Patch 3' --noUI" | Wait-Process

The gitlab-ci.yml job (executed by a runner with access to the codesys.exe):

configure-plc:
  tags:
    - codesys
  stage: configure-plc
  script:
    - Start-Process -Passthru -FilePath "C:\Program Files\CODESYS 3.5.17.30\CODESYS\Common\CODESYS.exe" -ArgumentList "--runscript='codesys_automation.py' --profile='CODESYS V3.5 SP17 Patch 3' --noUI" | Wait-Process

How do I make the runner behave just like the manual Poweshell and let it print out the programms stdout output?



Solution 1:[1]

Try this

configure-plc:
  tags:
    - codesys
  stage: configure-plc
  script:
    - '& "C:\Program Files\CODESYS 3.5.17.30\CODESYS\Common\CODESYS.exe" --runscript=codesys_automation.py --profile=CODESYS V3.5 SP17 Patch 3 --noUI'

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Sayan Daw