从詹金斯执行时,期望实用程序无法正常工作 [英] expect utility is not working when executing from jenkins

查看:103
本文介绍了从詹金斯执行时,期望实用程序无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个unix脚本,该脚本使用Expect实用程序进行交互执行.当我们从unix服务器运行时,此脚本运行良好.

如果我们从Jenkins运行此脚本,则该脚本无法正常工作.

下面是脚本

var="xxxxx"
expect -c "
    spawn sudo cp /abcd/sjws/config/obj.conf /abcd/sjws/config/obj.conf_jenkins
    expect {
    "Password:" { send $var\r;interact }
    }
    exit
    "

下面是我们从詹金斯(Jenkins)运行时的输出

spawn sudo cp /abcd/sjws/config/obj.conf /abcd/sjws/config/obj.conf_jenkins 
Password: 
Password:
Build step 'Execute shell' marked build as failure 
Finished: FAILURE

解决方案

由于Jenkins不在实际终端上运行它,因此interact不起作用,因为那里实际上没有任何用户交互. /p>

您可以将interact替换为

expect eof
wait

we have a unix script which uses expect utility for interactive execution. This script works well when we run from unix server.

If we run this script from Jenkins, it is not working.

Below is the script

var="xxxxx"
expect -c "
    spawn sudo cp /abcd/sjws/config/obj.conf /abcd/sjws/config/obj.conf_jenkins
    expect {
    "Password:" { send $var\r;interact }
    }
    exit
    "

Below is the output when we run from jenkins

spawn sudo cp /abcd/sjws/config/obj.conf /abcd/sjws/config/obj.conf_jenkins 
Password: 
Password:
Build step 'Execute shell' marked build as failure 
Finished: FAILURE

解决方案

Since Jenkins doesn't run it from an actual terminal, interact doesn't work, since there can't actually be any user interaction there.

You can replace interact with

expect eof
wait

这篇关于从詹金斯执行时,期望实用程序无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆