jenkins shell脚本错误执行调用nslookup

时间:2019-04-16 11:47:41

标签: jenkins groovy

我正在尝试从jenkins sh步骤执行一些代码。 当nslookup尝试搜索从export_zones.csv文件获取的第一个区域时,脚本似乎失败了。 从命令行执行相同的脚本是可以的。

我已经尝试将stderr重定向为null。

...
    for (i = 0; i < listOfServer.size(); i++) {
        def cmd = """\
cd ...;
for zone in \$(grep -v 'ZoneName' export_zones.csv | cut -d';' -f1); do nslookup -timeout=1 -retry=0 ${listOfServer[i]}.\${zone} xxx.yyy.www.zzz | egrep '^Name'; done;
"""          
        def serverName = sh returnStdout: true, script: cmd
... 

詹金斯的输出:

[test] Running shell script
+ cd ...
++ grep -v ZoneName export_zones.csv
++ cut '-d;' -f1
+ for zone in '$(grep -v '\''ZoneName'\'' export_zones.csv | cut -d'\'';'\'' -f1)'
+ nslookup -timeout=1 -retry=0 myhostname.myzone xxx.yyy.www.zzz
+ egrep '^Name'
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code 1
Finished: FAILURE

如您所见,当nslookup尝试搜索从export_zones.csv文件获取的第一个区域时,脚本将失败... 从命令行执行相同的脚本是可以的:

abc:~/test > for zone in $(grep -v 'ZoneName' export_zones.csv | cut -d';' -f1); do nslookup -timeout=1 -retry=0 myhostname.${zone} xxx.yyy.www.zzz | egrep '^Name'; done;
Name:   myhostname.aaa.bbb

有人可以帮助我理解为什么詹金斯(Jenkins)的跑步有不同的行为吗?

预先感谢

0 个答案:

没有答案
相关问题