我有一个简单的管道,只有一个任务来测试bash脚本。管道如下:
image: alpine/git
stages:
- test_branching
test_branch:
stage: test_branching
before_script:
- mkdir -p .common
- wget https://x.x.x.x/branching.sh > .common/test.sh && chmod +x .common/test.sh
- source .common/test.sh
script:
- test_pipe
- echo "app version is ${app_version}"bash脚本如下:
#!/bin/sh
function test_pipe () {
app_version="1.0.0.0-SNAPSHOT"
}问题是,无论出于什么原因,管道都无法识别脚本中的函数。这些日志是:
...
$ test_pipe
/scripts-1050-417479/step_script: eval: line 180: test_pipe: not found有人知道这是怎么回事吗?我想念很多Jenkins共享库,gitlab没有它,gitlab也没有在yml文件中包含脚本的功能。
我不想使用多项目管道,我需要这样做。这只是一个更复杂的流水线逻辑的例子。
提前感谢
发布于 2022-07-06 18:29:00
因为文献状态 before_script只是与script连接在一起,并在单个shell上运行。正在下载的脚本没有定义test_pipe。
..。gitlab没有在yml文件中包含脚本的功能。确实如此,只需在
|中使用YAML多行文字语法,例如:
script:
- |
echo "this"
echo "is"
echo "an \
example"https://stackoverflow.com/questions/72887609
复制相似问题