如何在jenkins pipeline(以前称为workflow)中启动bash login shell?

hgc7kmma  于 6个月前  发布在  Jenkins
关注(0)|答案(1)|浏览(91)

我刚刚开始将我的Jenkins作业转换为新的Jenkins Pipeline(工作流)工具,我在使用sh命令来使用bash登录shell时遇到了麻烦。
我试过

sh '''
#!/bin/bash -l
echo $0
'''

字符串
但是echo $0命令总是在交互式shell中执行,而不是在bash登录shell中执行。

zynd9foi

zynd9foi1#

@ Izzzego是对的!非常感谢!
所以要详细说明一下发生了什么。我使用sh''',这表示一个多行脚本。然而,得到的shell脚本被转储到jenkins节点将是一行,而不是第一行。所以我能够用这个来解决这个问题

sh '''#!/bin/bash -l
echo $0
# more stuff I needed to do,
# like use rvm, which doesn't work with shell, it needs bash.
'''

字符串

相关问题