I'm trying to run a script from jenkins (with using expect) - The script run correctly while I'm trying to run it from a jenkins slave locally. However, when I trigger a job to run it, the script fails and throws an error of:
11:05:47 the_user@ip.ip.ip.ip's password: Got SIGTERM, exiting
11:05:47 In exit
The script :
local_path=reports/
remote_path=/nfsserver
admin_user=my_user
admin_password=my_password
folder_to_copy='orion'_$(date '+%F_%H_%M')
cp -r $local_path $folder_to_copy
expect -c "
spawn scp -r $folder_to_copy/ admin_user@10.247.141.144:$remote_path
expect {
#expecting to get sign-on on an unssinged server
"*connecting*"
{
send "yes"\r;exp_continue
}
#expecting to get promt to enter password for scp
"*password:*"
{
send $admin_password\r;interact
}
}
exit
"
rm -rf $folder_to_copy
fi
can you please aid?
EDIT: Tried changing the password to hard-codded value, with and without brackets - nothing worked.
EDIT2: Tried replacing expect with sshpass but it failed on the same error.