Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Batch file 使用gitlab ci运行批处理文件并获取输出_Batch File_Continuous Integration_Gitlab Ci_Gitlab Ci Runner - Fatal编程技术网

Batch file 使用gitlab ci运行批处理文件并获取输出

Batch file 使用gitlab ci运行批处理文件并获取输出,batch-file,continuous-integration,gitlab-ci,gitlab-ci-runner,Batch File,Continuous Integration,Gitlab Ci,Gitlab Ci Runner,我已经用两个文件设置了我的gitlab项目:一个是一个批处理文件,它只打印hello world,另一个是执行管道的.gitlab ci.yml文件 批处理文件中的代码为: ECHO OFF ECHO 'Hello World' PAUSE gitlab-ci.yml文件具有测试阶段: test: stage: test script: - echo 'test' - chmod +x ./hello-world.bat 当我进行任何更改时,管

我已经用两个文件设置了我的gitlab项目:一个是一个批处理文件,它只打印
hello world
,另一个是执行管道的
.gitlab ci.yml
文件

批处理文件中的代码为:

ECHO OFF
ECHO 'Hello World'
PAUSE
gitlab-ci.yml文件具有测试阶段:

test:
    stage: test
    script:
        - echo 'test'
        - chmod +x ./hello-world.bat
当我进行任何更改时,管道将启动并成功执行,但我没有从批处理文件中获得所需的输出。我错过了什么

管道结果如下所示:


据我所见,您只向文件添加了+x权限,使其可执行,但从未实际运行过

如果将gitlab-ci.yml修改为:

test:
    stage: test
    script:
        - echo 'test'
        - chmod +x ./hello-world.bat
        - ./hello-world.bat
话虽如此,我不能100%肯定这会奏效。因为这似乎是在linux系统上运行的,.bat脚本适用于基于windows的系统。
请参阅bash脚本,了解这些脚本的工作原理。

据我所知,您只是向文件添加+x权限,使其可执行,但从未实际运行过它

如果将gitlab-ci.yml修改为:

test:
    stage: test
    script:
        - echo 'test'
        - chmod +x ./hello-world.bat
        - ./hello-world.bat
话虽如此,我不能100%肯定这会奏效。因为这似乎是在linux系统上运行的,.bat脚本适用于基于windows的系统。
请参考bash脚本了解这些脚本的工作原理。

在windows上使用gitlab ci runner时,我创建了一个python脚本,并将其推送到自托管github实例。在该python脚本中,我刚刚触发了.bat脚本,该脚本随后运行并在项目管道中显示输出

脚本如下所示:

导入子流程
子进程调用([r'C:\hello.bat']))

这就是我想要的。

在windows上使用gitlab ci runner时,我创建了一个python脚本,并将其推送到自托管github实例。在该python脚本中,我刚刚触发了.bat脚本,该脚本随后运行并在项目管道中显示输出

脚本如下所示:

导入子流程
子进程调用([r'C:\hello.bat']))
这就是我想要的