Docker化Jenkins中使用Groovy执行重定向创建文件失败
Jenkins流水线sh步骤重定向报错解决
报错原因:官方
jenkins/jenkins镜像基于Debian系统,默认sh指向dash而非bash,dash对部分bash语法支持有限,你当前的脚本写法触发了兼容性问题。解决方案1:指定用bash执行脚本
将sh步骤改为直接调用bash,写法如下:bash ''' echo " my commands " > state '''或者在脚本开头添加shebang指定bash:
sh ''' #!/bin/bash echo " my commands " > state '''解决方案2:调整脚本写法适配dash
若要继续使用dash,可简化echo写法或改用here-doc:# 单行内容写法 sh ''' echo 'my commands' > state ''' # 多行内容用here-doc sh ''' cat > state << EOF my commands EOF '''
内容的提问来源于stack exchange,提问作者deconya
相关产品推荐
相关产品推荐

