我正在尝试从jenkins运行脚本(使用expect) - 当我尝试从本地jenkins slave运行脚本时,脚本正确运行。 但是,当我触发一个作业来运行它时,脚本会失败并抛出错误:
11:05:47 the_user@ip.ip.ip.ip's password: Got SIGTERM, exiting
11:05:47 In exit
剧本:
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
你能帮忙吗?
编辑: 尝试将密码更改为硬编码值,带括号和不带括号 - 没有任何效果。
EDIT2: 尝试将期望替换为 sshpass ,但它在同一错误上失败。