Jenkins部署时报错getpass.py:83: GetPassWarning: Can not control echo on the terminal Warning: Password in

    在服务器上架设了jenkins之后,使用jenkins进行部署,但一直碰到报错。找不到原因,在百度、GOOGLE上也找了好多文章,多没有给出答案。报错的内容如下:

+ fab -f deploy/fabfile.py production deploy
/usr/local/python27/lib/python2.7/getpass.py:83: GetPassWarning: Can not control echo on the terminal.
  passwd = fallback_getpass(prompt, stream)
Warning: Password input may be echoed.

    根据经验这上面的提示的意思就是登录的时候被提示输入密码,但fabric不能捕获到控制台输出和输入,就出错了。但我明明在我的fabfile.py里写了密码,而fabric在执行的时候却不能提取密码。内容如下:

@task
def production():
    env.user = "root"
    env.hosts = ['123.1.101.23']
    env.passwords = {'123.1.101.23':'123456'}
    env.base_dir = "/home/testjenkins"

    推断应该是jenkins里有相关的设置导致,因为我同样的fabfile.py程序在其它的服务器上是可以运行的,在Google了一遍之后未找到答案,找到了一点东西(在fabric的文档里:http://docs.fabfile.org/en/1.12/usage/env.html),就是env里确实是有配置可以对此进行处理:

abort_on_prompts
Default: False
When True, Fabric will run in a non-interactive mode, calling abort anytime it would normally prompt the user for input (such as password prompts, “What host to connect to?” prompts, fabfile invocation of prompt, and so forth.) This allows users to ensure a Fabric session will always terminate cleanly instead of blocking on user input forever when unforeseen circumstances arise.
    但此值默认已经是false,而在另一篇文章中更是提到这是一个BUG,且在新的版本中已经修复:https://bugs.launchpad.net/pantheon/+bug/618795 截图如下:

    这个问题困扰了好多天了,上次碰到之后尝试找了很多文章,但未找到解决的办法,今天再好好地查找了一翻,依然没有答案。今天我在命令行下尝试运行fabric,

    执行命令:fab production deploy 执行时确实看到它的提示密码输入:

    最终依然在网上没有找到解决办法,都快准备重装python和jenkins了。但就在最后关头看到了网上一个不经意的地方用这种方式写了几惑密码:env.passwords = {'name@address': 'password'}。而我根据这种格式修改了fabfile.py中的passwords后OK了。经过多次测试,使用这种格式:env.passwords = {'root@123.1.101.23':'123456'}在命令行下和在jenkins的操作平台下都能成功,但目前尚不知道{'123.1.101.23':'123456'}这种格式为什么不行,因为我在其它的服务器上都是这样的写法。也许是fabric的配置的原因,或者是版本的原因。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

林戈的IT生涯

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值