git账号修改导致的jenkins发版失败

背景

项目中使用jenkins自动获取git代码并发版,都是通过execute shell方式,没有使用jenkins的Source Code Management。公司组织架构调整后,所有git的root账号被新技术总监收回,导致发版错误,显示:

GitLab: Your account has been blocked.
fatal: The remote end hung up unexpectedly

修复

1.申请新git账号

看提示应该是root账号改了密码或者是原发版账号被blocked。申请新git账号后把原jenkins服务器的公钥(通过cat /root/.ssh/id_rsa.pub 查看)配置到新git账号中,但是提示添加错误:

The form contains the following error:
   * Fingerprint has already been taken
添加公钥

原因是公钥配置在了其他账号中,只支持配置一次,所以需要新生成公钥配置在该账号中。

2.jenkins服务器生成新公钥

到jenkins服务器中,执行生成新公钥的命令并查看:

ssh-keygen -C '[email protected]' -t rsa 
cat /root/.ssh/id_rsa.pub 

将新生成的公钥配置到git中(如果没有配置到git中,会报以下错误,因为 git clone失败):

ssh_askpass: exec(/usr/libexec/openssh/ssh-askpass): No such file or directory
ssh_askpass: exec(/usr/libexec/openssh/ssh-askpass): No such file or directory
Permission denied, please try again.
ssh_askpass: exec(/usr/libexec/openssh/ssh-askpass): No such file or directory
Permission denied, please try again.
ssh_askpass: exec(/usr/libexec/openssh/ssh-askpass): No such file or directory
Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).
fatal: The remote end hung up unexpectedly

git添加新公钥成功后,在Your SSH keys里会出现新公钥信息


新公钥
3.SIT发版

SIT环境和Jenkins在一个服务器中,从git拷贝代码成功了并且发版成功。


4.UAT发版

UAT环境和Jenkins不在同一个服务器中,发版时报错:

ssh_askpass: exec(/usr/libexec/openssh/ssh-askpass): No such file or directory
Permission denied, please try again.
ssh_askpass: exec(/usr/libexec/openssh/ssh-askpass): No such file or directory
Permission denied, please try again.
ssh_askpass: exec(/usr/libexec/openssh/ssh-askpass): No such file or directory
Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).
lost connection

查了一下jenkins配置,使用jenkins的Execute sshell sript on remote host using ssh,远程连接到UAT服务器发版


jenkins链接其他服务器
5.ssh免密登陆其他服务器

因为Jenkins公钥重新生成了,所以保留在UAT服务器中的密钥也需要修改,拷贝新生成的公钥信息到UAT服务器

cd  /root/.ssh
vim authorized_keys

清除原来的公钥拷贝新公钥,然后再次发版,成功。


6. 总结

主要问题有两个,一个是无密访问git,一个是无密访问其他服务器。修改git账号后都重新配置就好了。

你可能感兴趣的:(git账号修改导致的jenkins发版失败)