简体   繁体   English

将Jenkins连接到AWS CodeCommit存储库

[英]Connecting Jenkins to AWS CodeCommit Repo

I have deployed a local Jenkins server (Windows host) and am attempting to connect to a repo in Amazon's AWS CodeCommit service. 我已经部署了本地Jenkins服务器(Windows主机),并试图连接到Amazon的AWS CodeCommit服务中的存储库。 I have configured the AWS CodeDeploy credentials in Jenkins (via the AWS CodeDeploy Plugin) with my AWS Access Key and Secre Key. 我已经使用我的AWS Access Key和Secre Key在Jenkins中配置了AWS CodeDeploy凭据(通过AWS CodeDeploy插件)。

I have created a new freestyle project, and have selected Git under Source Code Management and configirued: Repository URL - copied the SSH url from AWS Code Commit console Credentials - I have created a global credential and pointed it to my private key, and entered the passphrase. 我创建了一个新的自由式项目,并在“源代码管理”下选择了Git并进行了配置:存储库URL-从AWS Code Commit控制台凭证复制SSH URL-我创建了一个全局凭证并将其指向我的私钥,然后输入密码。

When configuring the Repo URL the following error is displayed: 配置回购URL时,显示以下错误:

Failed to connect to repository : Command "git.exe -c core.askpass=true ls-remote -h ssh://[REMOVED]@git-codecommit.us-east-1.amazonaws.com/v1/repos/[REMOVED]/ HEAD" returned status code 128: stdout: stderr: Permission denied (publickey). 无法连接到存储库:命令“ git.exe -c core.askpass = true ls-remote -h ssh:// [REMOVED] @ git-codecommit.us-east-1.amazonaws.com / v1 / repos / [ REMOVED] / HEAD”返回状态码128:stdout:stderr:权限被拒绝(公钥)。 fatal: Could not read from remote repository. 致命:无法从远程存储库读取。

Please make sure you have the correct access rights and the repository exists. 请确保您具有正确的访问权限,并且存储库存在。

Seems like a simple access error but for the life of me I cannot figure it out. 似乎是一个简单的访问错误,但我一生无法解决。 If I open my git bash and paste the above command in, I am presented with: 如果我打开git bash并将上面的命令粘贴到其中,则会看到:

You have successfully authenticated over SSH. 您已成功通过SSH进行身份验证。 You can use Git to interact with AWS CodeCommit. 您可以使用Git与AWS CodeCommit进行交互。 Connection to git-codecommit.us-east-1.amazonaws.com closed by remote host. 远程主机关闭了与git-codecommit.us-east-1.amazonaws.com的连接。 fatal: Could not read from remote repository. 致命:无法从远程存储库读取。

Please make sure you have the correct access rights and the repository exists. 请确保您具有正确的访问权限,并且存储库存在。

So It seems that the SSH connection is working. 因此,似乎SSH连接正在工作。 When I run: 当我跑步时:

ssh -vT [REMOVED]@git-codecommit.us-east-1.amazonaws.com

I get the following output: 我得到以下输出:

You have successfully authenticated over SSH. 您已成功通过SSH进行身份验证。 You can use Git to interact with AWS CodeCommit. 您可以使用Git与AWS CodeCommit进行交互。 Interactive shells are not supported.debug1: channel 0: free: client-session, nchannels 1 Connection to git-codecommit.us-east-1.amazonaws.com closed by remote host. 不支持交互式shell。调试1:通道0:免费:客户端会话,nchannels 1到git-codecommit.us-east-1.amazonaws.com的连接已由远程主机关闭。 Transferred: sent 4160, received 2368 bytes, in 0.2 seconds Bytes per second: sent 24893.3, received 14170.0 debug1: Exit status -1 传输:发送4160,接收2368字节,在0.2秒内字节每秒:发送24893.3,接收14170.0 debug1:退出状态-1

So it seems I really can access Code Commit okay. 看来我真的可以访问Code Commit了。

I have also verified that my IAM user is able to connect to CodeCommit by attached the CodeCommitFullAccess policy. 我还验证了我的IAM用户是否能够通过附加CodeCommitFullAccess策略连接到CodeCommit。 I have also cloned the repo using git bash, on the Windows host running Jenkins. 我还使用git bash在运行Jenkins的Windows主机上克隆了仓库。

Does anyone know how I can get Jenkins to connect without displaying the error? 有谁知道我该如何让Jenkins进行连接而不显示错误?

You mentioned in your question that you are using a passphrase for your SSH key. 您在问题中提到您正在为SSH密钥使用密码。 It looks like this is a known issue with Jenkins that has not been resolved as of now: JENKINS-20879 . 看起来这是Jenkins的一个已知问题,目前尚未解决: JENKINS-20879 I see some workarounds for Unix platforms, but not for Windows. 我看到了一些针对Unix平台的解决方法,但没有针对Windows的解决方法。 You might consider creating an SSH key for Jenkins that does not have a passphrase to work around this issue. 您可能会考虑为Jenkins创建一个没有密码的SSH密钥来解决此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM