Bash脚本在本地工作,但在CI中返回语法错误

Bash脚本在本地工作,但在CI中返回语法错误,bash,shell,sh,gitlab-ci,Bash,Shell,Sh,Gitlab Ci,在我的gitlab CI上,我运行以下简单脚本(.gitlab CI.yml): 在本地运行与脚本相同的命令可以正常工作: #!/bin/sh FILE="./file.txt" STR=$(cat $FILE) if grep -q "substring" <<< "$STR"; then echo "ok" fi /bin/sh不是bash,Im在阿尔卑斯山的图像中运行这个。我想没

在我的gitlab CI上,我运行以下简单脚本(.gitlab CI.yml):

在本地运行与脚本相同的命令可以正常工作:

#!/bin/sh

FILE="./file.txt"
STR=$(cat $FILE)

if grep -q "substring" <<< "$STR"; then
    echo "ok"
fi

/bin/sh
不是
bash
Im在阿尔卑斯山的图像中运行这个。我想没有bash,只有sh。如何检查sh中的子字符串?
或使用posix兼容的语法printf“%s\n”$str“| grep…
我的意思是
如果printf“%s\n”$str”| grep-q somehthing;然后
/bin/sh: eval: line 100: syntax error: unexpected redirection
#!/bin/sh

FILE="./file.txt"
STR=$(cat $FILE)

if grep -q "substring" <<< "$STR"; then
    echo "ok"
fi
This has a substring somewhere