Gitlab运行.bat文件后停止执行

时间:2019-05-24 15:15:16

标签: batch-file redis gitlab psexec

我有一种情况,我想从.gitlab-ci.yml文件启动Redis Server。

这是我的简化代码:

stages:
  - build_deploy

deploy_qa:
  stage: build_deploy
  tags:
  - windows
  script:
  - 'cd c:\PsTools'
  #port number:1111, password: xxx, server: developmentServer"
  - 'pstools-start-redis-server 1111 xxx developmentServer'
  #- do something else here after .bat executes
  environment:
    name: developmentServer
    url: http://someUrl
  when: manual

它会启动位于Gitlab CI服务器(Windows)上的pstools-start-redis-server.bat脚本:

:SetVars
    set _pwd=%2%
    set _port=%1%
    set _server=%3%
:Main
PsExec \\%_server% -d -accepteula -w c:\Redis c:\Redis\start-redis-server.bat %_port% "%_pwd%"

EXIT 0

然后使用psexec在Redis所在的开发服务器(Windows)上启动start-redis-server.bat脚本。

:SetVars
    set _pwd=%2%
    set _port=%1%
:Main
   redis-server --port %_port% --requirepass %_pwd%
EXIT 0

现在我的问题是,在运行start-redis-server.bat脚本之后,Gitlab会以信息“作业成功”结束,而以后未定义任何操作。

Running with gitlab-runner 11.7.0 (8bb608ff)
  on CISERVER fdbb21ea
Using Shell executor...
Running on CISERVER...
Fetching changes...
HEAD is now at e9bd103 Update .gitlab-ci.yml
Checking out e9bd103c as AC-641-qa-e2e-webapi-pipeline-fail...
Skipping Git submodules setup
$ cd c:\PsTools
$ pstools-start-redis-server 1111 xxx developmentServer

PsExec v2.2 - Execute processes remotely
Copyright (C) 2001-2016 Mark Russinovich
Sysinternals - www.sysinternals.com

Connecting to developmentServer...


Starting PSEXESVC service on developmentServer...


Connecting with PsExec service on developmentServer...


Starting c:\Redis\start-redis-server.bat on developmentServer...



c:\Redis\start-redis-server.bat started on developmentServer with process ID 6244.
Job succeeded

现在我已经读到在Windows上运行.bat脚本时必须使用call命令,并且我已经尝试过了,但是也许我做错了,因为它仍然不起作用。任何帮助将不胜感激。

致谢。

0 个答案:

没有答案