Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

expect utility is not working when executing from jenkins

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
like image 724
Kishore Tamire Avatar asked Jun 04 '13 09:06

Kishore Tamire


2 Answers

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
like image 144
Yam Marcovic Avatar answered Nov 16 '22 03:11

Yam Marcovic


Please use var='xxxxx' instead of var="xxxxx". Hope this help.

like image 44
klim Avatar answered Nov 16 '22 04:11

klim