我有一个 Jenkins 构建,它运行 Capistrano 部署作为构建后操作。
从控制台以 Jenkins 用户身份运行 Capistrano 任务绝对可以正常工作,并且没有密码提示(我之前在构建和登台服务器上都设置了 SSH 密钥)。但是,当通过 Jenkins 运行相同的脚本时,我突然收到密码提示,随后构建失败(不存在 TTY)。
[workspace] $ /bin/sh -xe /tmp/hudson7321493219694918714.sh
Performing Post build task...
Match found for : : True
Logical operation result is TRUE
Running script : cap _2.13.4_ deploy
[workspace] $ /bin/sh -xe /tmp/hudson1545664641721322948.sh
+ cap _2.13.4_ deploy
* executing `deploy'
* executing `deploy:update'
** transaction: start
* executing `deploy:update_code'
triggering before callbacks for `deploy:update_code'
[32m--> Updating code base with checkout strategy[0m
executing locally: "git ls-remote git@my.staging-server.com:my_project.git master"
command finished in 1200ms
* executing "git clone -q git@my.staging-server.com:my_project.git /var/www/staging/my_project/releases/20121029223619 && cd /var/www/staging/my_project/releases/20121029223619 && git checkout -q -b deploy 1fb11d669a6cb5a714d077162305dfcfaba82f01 && (echo 1fb11d669a6cb5a714d077162305dfcfaba82f01 > /var/www/staging/my_project/releases/20121029223619/REVISION)"
servers: ["my.staging-server.com"]
Password: stty: standard input: Inappropriate ioctl for device
stty: standard input: Inappropriate ioctl for device
stty: standard input: Inappropriate ioctl for device
*** [deploy:update_code] rolling back
* executing "rm -rf /var/www/staging/my_project/releases/20121029223619; true"
servers: ["my.staging-server.com"]
** [deploy:update_code] exception while rolling back: Capistrano::ConnectionError, connection failed for: my.staging-server.com (Net::SSH::AuthenticationFailed: not-specified)
connection failed for: my.staging-server.com (Net::SSH::AuthenticationFailed: not-specified)
POST BUILD TASK : FAILURE
看起来 Ruby 在通过 Jenkins 运行时可能没有选择我的 SSH 密钥(Net::SSH::AuthenticationFailed: not-specified
)?
有谁知道这里可能出了什么问题?