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
Please use var='xxxxx' instead of var="xxxxx". Hope this help.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With