启动节点服务器,执行其他操作,并终止Gitlab CI上的服务器



我有一个shell gitlab runner设置,我有下面的gitlab-ci.yml文件,在它安装必要的包并启动节点服务器之前,我必须在这里使用"start-npm run-start",否则它将永远停留在"serverstartedatxxxxxxx"。当我使用它时,它成功地终止了node.exe进程,但在那之后,它就永远挂在那里,我不得不手动取消构建,而且它永远不会运行after_script部分。

Test:
before_script:
- call npm install
- start npm run start
script:
- waitfor SomethingThatIsNeverHappening /t 3 & taskkill /t /f /im node.exe & exit 0
after_script:
- echo HELLLLLLLLLLO

我的问题是,一个人会如何做这样的事情?我想在启动服务器、做一些事情,然后终止服务器的地方有这个确切的代码,但在这之后,它应该会成功地终止构建,并显示正确的状态,如失败/通过gitlab。现在它完成了文件中的所有内容,但在完成所有内容后,应用程序将永远挂起,而不是终止并显示成功。如果我没有后记部分,它将永远挂在最后。

注意:我尝试过退出0和退出1,但他们什么都不做。

相关日志:

$ start npm run start
$ waitfor SomethingThatIsNeverHappening /t 3 & taskkill /t /f /im node.exe & exit 0
ERROR: Timed out waiting for 'SomethingThatIsNeverHappening'.
SUCCESS: The process with PID 2396 (child process of PID 9196) has been terminated.
SUCCESS: The process with PID 10040 (child process of PID 9196) has been terminated.
SUCCESS: The process with PID 8452 (child process of PID 9196) has been terminated.
SUCCESS: The process with PID 11172 (child process of PID 9196) has been terminated.
SUCCESS: The process with PID 5416 (child process of PID 9196) has been terminated.
SUCCESS: The process with PID 9196 (child process of PID 8648) has been terminated.
SUCCESS: The process with PID 8648 (child process of PID 8272) has been terminated.
SUCCESS: The process with PID 8272 (child process of PID 8512) has been terminated.

在这一点之后,它只是永远保持运行,没有另一行新的输出

我可以通过使用powershell作为我选择的shell来解决这个问题,该shell在runner文件夹的config.toml文件中指定。在将命令转换为powershell友好命令后,一切都很好。

最新更新