我在窗户上设置了一个gitlab运行程序。我有一个build.sh
脚本,仅在其中显示“ Hello world”。我在gitlab-ci.yml
文件中提供了以下行:
build:
stage: build
script:
- ./build.sh
运行程序执行此作业,但不打印我在build.sh
文件中提到的echo命令。但是,如果我将扩展名更改为.bat
,它将起作用并显示输出。 gitlab-runner
被设置用于shell。可能是什么原因?还是我缺少什么?
答案 0 :(得分:1)
GitLab将输出任何最终写入STDOUT或STDERR的内容。不看整个脚本就很难说发生了什么,但我想您实际上并没有在STDOUT上回声。这就是为什么输出未最终出现在CI输出中的原因。
为了测试这一点,我在GitLab.com上创建了一个测试项目。测试中的一个不同之处是我的CI YAML脚本命令是sh build.sh
。这是因为该脚本不可执行,因此无法使用./build.sh
执行。
builds.sh
文件:
#!/bin/bash
echo "This is output from build.sh"
.gitlab-ci.yml
文件:
build:
stage: build
script:
- sh build.sh
构建输出:
Running with gitlab-runner 12.3.0-rc1 (afb9fab4)
on docker-auto-scale 72989761
...
Fetching changes with git depth set to 50...
Initialized empty Git repository in /builds/dblessing/ci-output-test/.git/
Created fresh repository.
Checking out cfe8a4ee as master...
Skipping Git submodules setup
$ sh build.sh
This is output from build.sh
Job succeeded